From 2a1749d8e8f97fe930cce6cc7a434714ff05ffd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BD=D0=B8=D1=8F=D1=80=20=D0=90=D0=B3=D0=BB?= =?UTF-8?q?=D0=B8=D1=83=D0=BB=D0=BB=D0=BE=D0=B2?= Date: Fri, 17 Mar 2023 17:46:15 +0400 Subject: [PATCH] =?UTF-8?q?=D0=91=D0=BE=D0=BB=D1=8C=D1=88=D0=B5=20=D0=BD?= =?UTF-8?q?=D0=B5=20=D0=B2=D0=BE=D0=B7=D0=B2=D1=80=D0=B0=D1=89=D0=B0=D0=B5?= =?UTF-8?q?=D1=82=D1=81=D1=8F=20=D1=81=D1=82=D0=B0=D1=82=D1=83=D1=81=20?= =?UTF-8?q?=D0=B7=D0=B0=D0=BA=D0=B0=D0=B7=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ConfectionaryBusinessLogic/OrderLogic.cs | 12 ++++++------ Confectionery/FormMain.cs | 8 ++++---- .../BusinessLogicsContracts/IOrderLogic.cs | 7 +++---- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/ConfectionaryBusinessLogic/OrderLogic.cs b/ConfectionaryBusinessLogic/OrderLogic.cs index 0b1950b..2548654 100644 --- a/ConfectionaryBusinessLogic/OrderLogic.cs +++ b/ConfectionaryBusinessLogic/OrderLogic.cs @@ -41,9 +41,9 @@ namespace ConfectioneryBusinessLogic.BusinessLogics return true; } - public OrderStatus? TakeOrderInWork(OrderBindingModel model) => SetOrderStatus(model, OrderStatus.Выполняется); - public OrderStatus? DeliveryOrder(OrderBindingModel model) => SetOrderStatus(model, OrderStatus.Выдан); - public OrderStatus? FinishOrder(OrderBindingModel model) + public bool TakeOrderInWork(OrderBindingModel model) => SetOrderStatus(model, OrderStatus.Выполняется); + public bool DeliveryOrder(OrderBindingModel model) => SetOrderStatus(model, OrderStatus.Выдан); + public bool FinishOrder(OrderBindingModel model) { model.DateImplement = DateTime.Now; return SetOrderStatus(model, OrderStatus.Готов); @@ -84,7 +84,7 @@ namespace ConfectioneryBusinessLogic.BusinessLogics return true; } - private OrderStatus? SetOrderStatus(OrderBindingModel model, OrderStatus orderStatus) + private bool SetOrderStatus(OrderBindingModel model, OrderStatus orderStatus) { // Находим статус заказа по его айди var vmodel = _orderStorage.GetElement(new() { Id = model.Id }); @@ -125,9 +125,9 @@ namespace ConfectioneryBusinessLogic.BusinessLogics if (_orderStorage.Update(model) == null) { _logger.LogWarning("Update operation failed"); - return null; + return false; } - return orderStatus; + return true; } public OrderViewModel? ReadElement(OrderSearchModel model) diff --git a/Confectionery/FormMain.cs b/Confectionery/FormMain.cs index 09ae552..fcc56d2 100644 --- a/Confectionery/FormMain.cs +++ b/Confectionery/FormMain.cs @@ -87,8 +87,8 @@ namespace ConfectioneryView _logger.LogInformation(" No{id}. ' '", id); try { - var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel { Id = id }) ; - if (operationResult == null) + var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel { Id = id }); + if (!operationResult) { throw new Exception(" . ."); } @@ -116,7 +116,7 @@ namespace ConfectioneryView Id = id, Status = orderStatus }); - if (operationResult == null) + if (!operationResult) { throw new Exception(" . ."); } @@ -141,7 +141,7 @@ namespace ConfectioneryView var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel { Id = id }); - if (operationResult == null) + if (!operationResult) { throw new Exception(" . ."); } diff --git a/ConfectioneryContracts/BusinessLogicsContracts/IOrderLogic.cs b/ConfectioneryContracts/BusinessLogicsContracts/IOrderLogic.cs index 3de0a87..dfd1797 100644 --- a/ConfectioneryContracts/BusinessLogicsContracts/IOrderLogic.cs +++ b/ConfectioneryContracts/BusinessLogicsContracts/IOrderLogic.cs @@ -1,7 +1,6 @@ using ConfectioneryContracts.BindingModels; using ConfectioneryContracts.SearchModels; using ConfectioneryContracts.ViewModels; -using ConfectioneryDataModels.Enums; namespace ConfectioneryContracts.BusinessLogicsContracts { @@ -10,8 +9,8 @@ namespace ConfectioneryContracts.BusinessLogicsContracts List? ReadList(OrderSearchModel? model); OrderViewModel? ReadElement(OrderSearchModel model); bool CreateOrder(OrderBindingModel model); - OrderStatus? TakeOrderInWork(OrderBindingModel model); - OrderStatus? FinishOrder(OrderBindingModel model); - OrderStatus? DeliveryOrder(OrderBindingModel model); + bool TakeOrderInWork(OrderBindingModel model); + bool FinishOrder(OrderBindingModel model); + bool DeliveryOrder(OrderBindingModel model); } }