From 2093186453cc531445a2c83c52a9913a5a872b26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=9F=D0=BE=D0=BB?= =?UTF-8?q?=D0=B5=D0=B2=D0=BE=D0=B9?= Date: Sun, 12 Feb 2023 18:21:48 +0400 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B4=D0=B5=D0=BB=D0=B0=D0=BD?= =?UTF-8?q?=D0=B0=20=D0=BB=D0=BE=D0=B3=D0=B8=D0=BA=D0=B0=20=D0=B7=D0=B0?= =?UTF-8?q?=D0=BA=D0=B0=D0=B7=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FlowerShopBusinessLogic/OrderLogic.cs | 51 +++++++++++++++++-- 1 file changed, 48 insertions(+), 3 deletions(-) diff --git a/FlowerShop/FlowerShopBusinessLogic/OrderLogic.cs b/FlowerShop/FlowerShopBusinessLogic/OrderLogic.cs index 7e603f3..d21bffe 100644 --- a/FlowerShop/FlowerShopBusinessLogic/OrderLogic.cs +++ b/FlowerShop/FlowerShopBusinessLogic/OrderLogic.cs @@ -57,16 +57,61 @@ namespace FlowerShopBusinessLogic.BusinessLogics public bool TakeOrderInWork(OrderBindingModel model) { - throw new NotImplementedException(); + CheckModel(model, false); + + if (model.Status != OrderStatus.Accepted) + { + _logger.LogWarning("Invalid order status"); + return false; + } + + model.Status = OrderStatus.Processing; + + if (_orderStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + } + + return true; } public bool FinishOrder(OrderBindingModel model) { - throw new NotImplementedException(); + CheckModel(model, false); + + if (model.Status != OrderStatus.Processing) + { + _logger.LogWarning("Invalid order status"); + return false; + } + + model.Status = OrderStatus.Ready; + + if (_orderStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + } + + return true; } public bool DeliveryOrder(OrderBindingModel model) { - throw new NotImplementedException(); + CheckModel(model, false); + + if (model.Status != OrderStatus.Ready) + { + _logger.LogWarning("Invalid order status"); + return false; + } + + model.Status = OrderStatus.Delivered; + + if (_orderStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + } + + return true; } private void CheckModel(OrderBindingModel model, bool withParams = true)