From 191b53b77e122a171144c0a68594fc8cc9e6eee7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D1=80=D0=B0=D1=82=20=D0=97=D0=B0=D1=80=D0=B3?= =?UTF-8?q?=D0=B0=D1=80=D0=BE=D0=B2?= Date: Fri, 2 Jun 2023 12:12:41 +0400 Subject: [PATCH] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=BB=D0=BE=D0=B3=D0=B8=D0=BA=D0=B8=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 --- Pizzeria/PizzeriaBusinessLogic/OrderLogic.cs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/Pizzeria/PizzeriaBusinessLogic/OrderLogic.cs b/Pizzeria/PizzeriaBusinessLogic/OrderLogic.cs index 824ad10..2aaeb2a 100644 --- a/Pizzeria/PizzeriaBusinessLogic/OrderLogic.cs +++ b/Pizzeria/PizzeriaBusinessLogic/OrderLogic.cs @@ -36,22 +36,21 @@ namespace PizzeriaBusinessLogic _logger.LogInformation("ReadList. Count:{Count}", list.Count); return list; } - public OrderViewModel? ReadElement(OrderSearchModel model) { if (model == null) { throw new ArgumentNullException(nameof(model)); } - _logger.LogInformation("ReadElement. ClientId: {ClientId}. ImplementerId: {ImplementerId}. Status: {Status}. DateFrom: {DateFrom}. DateTo: {DateTo}. Id: {Id}", - model.ClientId, model.ImplementerId, model.Status, model.DateFrom, model.DateTo, model.Id); + _logger.LogInformation("ReadElement. ClientId:{ClientId}.Status:{Status}.ImplementerId:{ImplementerId}.DateFrom:{DateFrom}.DateTo:{DateTo}OrderId:{Id}", + model.ClientId, model.Status, model.ImplementerId, model.DateFrom, model.DateTo, model.Id); var element = _orderStorage.GetElement(model); if (element == null) { _logger.LogWarning("ReadElement element not found"); return null; } - _logger.LogInformation("ReadElement find. Id: {Id}", element.Id); + _logger.LogInformation("ReadElement find. Id:{Id}", element.Id); return element; } public bool CreateOrder(OrderBindingModel model) @@ -94,9 +93,9 @@ namespace PizzeriaBusinessLogic } if (model.Count <= 0) { - throw new ArgumentException("Количество пиццы в заказе не может быть меньше 1", nameof(model.Count)); + throw new ArgumentException("Количество изделий в заказе не может быть меньше 1", nameof(model.Count)); } - if (model.Sum < 1) + if (model.Sum <= 0) { throw new ArgumentException("Стоимость заказа на может быть меньше 1", nameof(model.Sum)); } @@ -116,14 +115,14 @@ namespace PizzeriaBusinessLogic }); if (element == null) { - throw new ArgumentNullException(nameof(element)); + throw new InvalidOperationException(nameof(element)); } model.DateCreate = element.DateCreate; model.PizzaId = element.PizzaId; + model.DateImplement = element.DateImplement; model.ClientId = element.ClientId; if (!model.ImplementerId.HasValue) model.ImplementerId = element.ImplementerId; - model.DateImplement = element.DateImplement; model.Status = element.Status; model.Count = element.Count; model.Sum = element.Sum; @@ -140,7 +139,7 @@ namespace PizzeriaBusinessLogic return true; } _logger.LogWarning("Changing status operation faled: Current-{Status}:required-{requiredStatus}.", model.Status, requiredStatus); - throw new ArgumentException($"Невозможно присвоить статус {requiredStatus} заказу с текущим статусом {model.Status}"); + throw new InvalidOperationException($"Невозможно приствоить статус {requiredStatus} заказу с текущим статусом {model.Status}"); } } }