From df2c68349c84904534ab7e30e37ab8169b250d6e Mon Sep 17 00:00:00 2001 From: "ityurner02@mail.ru" Date: Sun, 16 Apr 2023 23:14:54 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A7=D1=82=D0=BE-=D1=82=D0=BE=20=D1=80=D0=B0?= =?UTF-8?q?=D0=B1=D0=BE=D1=82=D0=B0=D0=B5=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BusinessLogic/OrderLogic.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/PlumbingRepair/PlumbingRepairBusinessLogic/BusinessLogic/OrderLogic.cs b/PlumbingRepair/PlumbingRepairBusinessLogic/BusinessLogic/OrderLogic.cs index 84f57c9..de0eeff 100644 --- a/PlumbingRepair/PlumbingRepairBusinessLogic/BusinessLogic/OrderLogic.cs +++ b/PlumbingRepair/PlumbingRepairBusinessLogic/BusinessLogic/OrderLogic.cs @@ -49,6 +49,20 @@ namespace PlumbingRepairBusinessLogic.BusinessLogic throw new ArgumentNullException(nameof(model)); } + OrderViewModel? order = _orderStorage.GetElement(new OrderSearchModel + { + Id = model.Id + }); + + if (order == null) + { + _logger.LogWarning("Status update to " + newStatus.ToString() + " operation failed. Order not found."); + return false; + } + + model.Status = order.Status; + if (!model.ImplementerId.HasValue) model.ImplementerId = order.ImplementerId; + if (model.Status + 1 != newStatus) { _logger.LogWarning("Status update to " + newStatus.ToString() + " operation failed. Order status incorrect."); @@ -71,7 +85,6 @@ namespace PlumbingRepairBusinessLogic.BusinessLogic if (_orderStorage.Update(model) == null) { - model.Status--; _logger.LogWarning("Update operation failed"); return false; }