From 46c1d78dd92570f6087c6d259269bdc6e18c2413 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=BA=20=D0=98=D0=B3=D0=BE=D1=80=D1=8C?= Date: Wed, 15 Feb 2023 00:22:52 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9A=D0=BE=D1=80=D1=80=D0=B5=D0=BA=D1=82?= =?UTF-8?q?=D0=B8=D1=80=D0=BE=D0=B2=D0=BA=D0=B0=20=D0=BB=D0=BE=D0=B3=D0=B8?= =?UTF-8?q?=D0=BA=D0=B8=20=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F=20=D1=81=D1=82=D0=B0=D1=82=D1=83=D1=81=D0=B0=20=D0=B7?= =?UTF-8?q?=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 --- .../BusinessLogics/OrderLogic.cs | 24 ++++++++++++------- .../Models/Order.cs | 5 +++- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogics/OrderLogic.cs b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogics/OrderLogic.cs index 039fefd..3b4e82d 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogics/OrderLogic.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogics/OrderLogic.cs @@ -32,7 +32,7 @@ namespace BlacksmithWorkShopBusinessLogic.BusinessLogics public bool CreateOrder(OrderBindingModel model) { CheckModel(model); - if ((int)model.Status > -2) + if (model.Status == OrderStatus.Неизвестен) { model.Status = OrderStatus.Принят; } @@ -46,14 +46,16 @@ namespace BlacksmithWorkShopBusinessLogic.BusinessLogics _logger.LogWarning("Create order operation failed"); return false; } - model.Status = OrderStatus.Принят; return true; } public bool TakeOrderInWork(OrderBindingModel model) { - OrderViewModel? vm = _orderStorage.GetElement(new() { Id = model.Id }); + OrderViewModel? vm = _orderStorage.GetElement(new() + { + Id = model.Id + }); model.Status = vm?.Status ?? OrderStatus.Неизвестен; - if ((int)model.Status > -1) + if (model.Status == OrderStatus.Принят) { model.Status = OrderStatus.Выполняется; } @@ -69,9 +71,12 @@ namespace BlacksmithWorkShopBusinessLogic.BusinessLogics } public bool FinishOrder(OrderBindingModel model) { - OrderViewModel? vm = _orderStorage.GetElement(new() { Id = model.Id }); + OrderViewModel? vm = _orderStorage.GetElement(new() + { + Id = model.Id + }); model.Status = vm?.Status ?? OrderStatus.Неизвестен; - if ((int)model.Status > 0) + if (model.Status == OrderStatus.Выполняется) { model.Status = OrderStatus.Готов; model.DateImplement = DateTime.Now; @@ -88,9 +93,12 @@ namespace BlacksmithWorkShopBusinessLogic.BusinessLogics } public bool DeliveryOrder(OrderBindingModel model) { - OrderViewModel? vm = _orderStorage.GetElement(new() { Id = model.Id }); + OrderViewModel? vm = _orderStorage.GetElement(new() + { + Id = model.Id + }); model.Status = vm?.Status ?? OrderStatus.Неизвестен; - if ((int)model.Status > 1) + if (model.Status == OrderStatus.Готов) { model.Status = OrderStatus.Выдан; } diff --git a/BlacksmithWorkshop/BlacksmithWorkshopListImplement/Models/Order.cs b/BlacksmithWorkshop/BlacksmithWorkshopListImplement/Models/Order.cs index 20ea5d1..448cbd8 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopListImplement/Models/Order.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopListImplement/Models/Order.cs @@ -52,7 +52,10 @@ namespace BlacksmithWorkshopListImplement.Models return; } Status = model.Status; - DateImplement = model.DateImplement; + if (model.DateImplement != null) + { + DateImplement = model.DateImplement; + } } public OrderViewModel GetViewModel => new() {