From 49152e95c5e85bddb6d1bd845753dfd91b3c9097 Mon Sep 17 00:00:00 2001 From: Danila_Mochalov Date: Fri, 10 Mar 2023 19:13:41 +0400 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LawFirm/LawFirm/FormCreateOrder.cs | 1 - .../BusinessLogics/OrderLogic.cs | 3 +-- .../BindingModels/OrderBindingModel.cs | 2 -- .../LawFirmDataModels/Models/IOrderModel.cs | 1 - .../Implements/OrderStorage.cs | 26 ++++++++++++++----- LawFirm/LawFirmListImplements/Models/Order.cs | 10 ------- 6 files changed, 21 insertions(+), 22 deletions(-) diff --git a/LawFirm/LawFirm/FormCreateOrder.cs b/LawFirm/LawFirm/FormCreateOrder.cs index 7ae32c0..d1c66e1 100644 --- a/LawFirm/LawFirm/FormCreateOrder.cs +++ b/LawFirm/LawFirm/FormCreateOrder.cs @@ -103,7 +103,6 @@ namespace LawFirmView var operationResult = _logicO.CreateOrder(new OrderBindingModel { DocumentId = Convert.ToInt32(comboBoxDocument.SelectedValue), - DocumentName = comboBoxDocument.Text, Count = Convert.ToInt32(textBoxCount.Text), Sum = Convert.ToDouble(textBoxSum.Text) }); diff --git a/LawFirm/LawFirmBusinessLogic/BusinessLogics/OrderLogic.cs b/LawFirm/LawFirmBusinessLogic/BusinessLogics/OrderLogic.cs index 75cacbd..36422a4 100644 --- a/LawFirm/LawFirmBusinessLogic/BusinessLogics/OrderLogic.cs +++ b/LawFirm/LawFirmBusinessLogic/BusinessLogics/OrderLogic.cs @@ -59,7 +59,6 @@ namespace LawFirmBusinessLogic.BusinessLogics { Id = viewModel.Id, DocumentId = viewModel.DocumentId, - DocumentName = viewModel.DocumentName, Status = viewModel.Status, DateCreate = viewModel.DateCreate, DateImplement = viewModel.DateImplement, @@ -67,7 +66,7 @@ namespace LawFirmBusinessLogic.BusinessLogics Sum = viewModel.Sum }; - CheckModel(model); + CheckModel(model, false); if (model.Status + 1 != newStatus) { _logger.LogWarning("Status update to " + newStatus.ToString() +" operation failed. Order status incorrect."); diff --git a/LawFirm/LawFirmContracts/BindingModels/OrderBindingModel.cs b/LawFirm/LawFirmContracts/BindingModels/OrderBindingModel.cs index c893bdd..f2f3566 100644 --- a/LawFirm/LawFirmContracts/BindingModels/OrderBindingModel.cs +++ b/LawFirm/LawFirmContracts/BindingModels/OrderBindingModel.cs @@ -12,8 +12,6 @@ namespace LawFirmContracts.BindingModels { public int DocumentId { get; set; } - public string DocumentName { get; set; } = string.Empty; - public int Count { get; set; } public double Sum { get; set; } diff --git a/LawFirm/LawFirmDataModels/Models/IOrderModel.cs b/LawFirm/LawFirmDataModels/Models/IOrderModel.cs index 73bffa1..79d5a0b 100644 --- a/LawFirm/LawFirmDataModels/Models/IOrderModel.cs +++ b/LawFirm/LawFirmDataModels/Models/IOrderModel.cs @@ -10,7 +10,6 @@ namespace LawFirmDataModels.Models public interface IOrderModel : IId { int DocumentId { get; } - string DocumentName { get; } int Count { get; } double Sum { get; } OrderStatus Status { get; } diff --git a/LawFirm/LawFirmListImplements/Implements/OrderStorage.cs b/LawFirm/LawFirmListImplements/Implements/OrderStorage.cs index 772a901..9e0fd88 100644 --- a/LawFirm/LawFirmListImplements/Implements/OrderStorage.cs +++ b/LawFirm/LawFirmListImplements/Implements/OrderStorage.cs @@ -30,7 +30,7 @@ namespace LawFirmListImplements.Implements { if (model.Id.HasValue && order.Id == model.Id) { - return order.GetViewModel; + return GetViewModel(order); } } return null; @@ -47,7 +47,7 @@ namespace LawFirmListImplements.Implements { if (order.Id == model.Id) { - result.Add(order.GetViewModel); + result.Add(GetViewModel(order)); } } return result; @@ -58,7 +58,7 @@ namespace LawFirmListImplements.Implements var result = new List(); foreach (var order in _source.Orders) { - result.Add(order.GetViewModel); + result.Add(GetViewModel(order)); } return result; } @@ -79,7 +79,7 @@ namespace LawFirmListImplements.Implements return null; } _source.Orders.Add(newOrder); - return newOrder.GetViewModel; + return GetViewModel(newOrder); } public OrderViewModel? Update(OrderBindingModel model) @@ -89,7 +89,7 @@ namespace LawFirmListImplements.Implements if (order.Id == model.Id) { order.Update(model); - return order.GetViewModel; + return GetViewModel(order); } } return null; @@ -102,11 +102,25 @@ namespace LawFirmListImplements.Implements { var element = _source.Orders[i]; _source.Orders.RemoveAt(i); - return element.GetViewModel; + return GetViewModel(element); } } return null; } + private OrderViewModel GetViewModel(Order order) + { + var viewModel = order.GetViewModel; + foreach (var document in _source.Documents) + { + if (document.Id == order.DocumentId) + { + viewModel.DocumentName = document.DocumentName; + break; + } + } + return viewModel; + } + } } diff --git a/LawFirm/LawFirmListImplements/Models/Order.cs b/LawFirm/LawFirmListImplements/Models/Order.cs index aed790d..727b687 100644 --- a/LawFirm/LawFirmListImplements/Models/Order.cs +++ b/LawFirm/LawFirmListImplements/Models/Order.cs @@ -14,8 +14,6 @@ namespace LawFirmListImplements.Models { public int DocumentId { get; private set; } - public string DocumentName { get; private set; } = string.Empty; - public int Count { get; private set; } public double Sum { get; private set; } @@ -37,7 +35,6 @@ namespace LawFirmListImplements.Models return new Order { DocumentId = model.DocumentId, - DocumentName = model.DocumentName, Count = model.Count, Sum = model.Sum, Status = model.Status, @@ -53,20 +50,13 @@ namespace LawFirmListImplements.Models { return; } - DocumentId = model.DocumentId; - DocumentName = model.DocumentName; - Count = model.Count; - Sum = model.Sum; Status = model.Status; - DateCreate = model.DateCreate; DateImplement = model.DateImplement; - Id = model.Id; } public OrderViewModel GetViewModel => new() { DocumentId = DocumentId, - DocumentName = DocumentName, Count = Count, Sum = Sum, DateCreate = DateCreate,