This commit is contained in:
Danil Markov 2023-04-21 13:44:19 +04:00
parent fd36910364
commit 1779a803a9
5 changed files with 15 additions and 13 deletions

View File

@ -52,7 +52,7 @@ namespace LawFirmBusinessLogic.BusinessLogics
{
model.DateImplement = viewModel.DateImplement;
}
CheckModel(model);
CheckModel(model, false);
if (_orderStorage.Update(model) == null)
{
model.Status--;

View File

@ -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>();
}

View File

@ -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)
{

View File

@ -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;
}

View File

@ -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