Markov D.P. LabWork03Hard #11
@ -52,7 +52,7 @@ namespace LawFirmBusinessLogic.BusinessLogics
|
||||
{
|
||||
model.DateImplement = viewModel.DateImplement;
|
||||
}
|
||||
CheckModel(model);
|
||||
CheckModel(model, false);
|
||||
if (_orderStorage.Update(model) == null)
|
||||
{
|
||||
model.Status--;
|
||||
|
@ -27,15 +27,18 @@ namespace LawFirmFileImplement
|
||||
{
|
||||
Blanks = LoadData(BlankFileName, "Blank", x => Blank.Create(x)!)!;
|
||||
Documents = LoadData(DocumentFileName, "Document", x => Document.Create(x)!)!;
|
||||
Orders = new List<Order>();
|
||||
Orders = LoadData(DocumentFileName, "Order", x => Document.Create(x)!)!;
|
||||
}
|
||||
private static List<T>? LoadData<T>(string filename, string xmlNodeName,
|
||||
Func<XElement, T> selectFunction)
|
||||
{
|
||||
if (File.Exists(filename))
|
||||
{
|
||||
return
|
||||
XDocument.Load(filename)?.Root?.Elements(xmlNodeName)?.Select(selectFunction)?.ToList();
|
||||
return XDocument.Load(filename)?.
|
||||
Root?.
|
||||
Elements(xmlNodeName)?.
|
||||
Select(selectFunction)?.
|
||||
ToList();
|
||||
}
|
||||
return new List<T>();
|
||||
}
|
||||
|
@ -50,14 +50,14 @@ namespace LawFirmFileImplement.Implements
|
||||
}
|
||||
public DocumentViewModel? Update(DocumentBindingModel model)
|
||||
{
|
||||
var ship = source.Documents.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (ship == null)
|
||||
var document = source.Documents.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (document == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
ship.Update(model);
|
||||
document.Update(model);
|
||||
source.SaveDocuments();
|
||||
return ship.GetViewModel;
|
||||
return document.GetViewModel;
|
||||
}
|
||||
public DocumentViewModel? Delete(DocumentBindingModel model)
|
||||
{
|
||||
|
@ -38,10 +38,10 @@ namespace LawFirmFileImplement.Implements
|
||||
private OrderViewModel GetViewModel(Order order)
|
||||
{
|
||||
var viewModel = order.GetViewModel;
|
||||
var ship = source.Documents.FirstOrDefault(x => x.Id == order.DocumentId);
|
||||
if (ship != null)
|
||||
var document = source.Documents.FirstOrDefault(x => x.Id == order.DocumentId);
|
||||
if (document != null)
|
||||
{
|
||||
viewModel.DocumentName = ship.DocumentName;
|
||||
viewModel.DocumentName = document.DocumentName;
|
||||
}
|
||||
return viewModel;
|
||||
}
|
||||
|
@ -11,8 +11,7 @@ namespace LawFirmFileImplement.Models
|
||||
public string DocumentName { get; private set; } = string.Empty;
|
||||
public double Price { get; private set; }
|
||||
public Dictionary<int, int> Blanks { get; private set; } = new();
|
||||
private Dictionary<int, (IBlankModel, int)>? _productBlanks =
|
||||
null;
|
||||
private Dictionary<int, (IBlankModel, int)>? _productBlanks = null;
|
||||
public Dictionary<int, (IBlankModel, int)> DocumentBlanks
|
||||
{
|
||||
get
|
||||
|
Loading…
Reference in New Issue
Block a user