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 ee6a2d0..0865dd2 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); } }