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)