diff --git a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OrderLogic.cs b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OrderLogic.cs index c7bb230..d11a049 100644 --- a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OrderLogic.cs +++ b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OrderLogic.cs @@ -62,17 +62,11 @@ namespace FurnitureAssemblyBusinessLogic { return false; } - _logger.LogWarning($""); - if (modelNew.ImplementerId.HasValue) - { - _logger.LogWarning($"Order {model.Id} is already in Work"); - throw new InvalidOperationException($"Order {model.Id} is already in Work"); - } model.Status = modelNew.Status; if (!ChangeStatus(model, OrderStatus.Выполняется)) { _logger.LogWarning("Order's status is wrong"); - return false; + throw new InvalidOperationException("Order's status is wrong"); } _orderStorage.Update(model); return true; @@ -86,21 +80,21 @@ namespace FurnitureAssemblyBusinessLogic } model.ImplementerId = modelNew.ImplementerId; model.Status = modelNew.Status; - if (!_shopLogic.AddFurnituresAtShops(new FurnitureBindingModel() { Id = modelNew.FurnitureId }, modelNew.Count)) - { - if (!ChangeStatus(model, OrderStatus.Ожидание)) - { - _logger.LogWarning($"Order's status {model.Status} is wrong"); - return false; - } - _orderStorage.Update(model); - _logger.LogWarning("There are not empty places at shops. Replenishment is impossible"); - return false; - } - if (!ChangeStatus(model, OrderStatus.Готов)) { _logger.LogWarning("Order's status is wrong"); + throw new InvalidOperationException("Order's status is wrong"); + } + if (!_shopLogic.AddFurnituresAtShops(new FurnitureBindingModel() { Id = modelNew.FurnitureId }, modelNew.Count)) + { + model.Status--; + if (!ChangeStatus(model, OrderStatus.Ожидание)) + { + _logger.LogWarning($"Order's status {model.Status} is wrong"); + throw new InvalidOperationException("Order's status is wrong"); + } + _orderStorage.Update(model); + _logger.LogWarning("There are not empty places at shops. Replenishment is impossible"); return false; } model.DateImplement = DateTime.Now;