From 30f244c552a3420b31445d18d43c5226d1f1b7e2 Mon Sep 17 00:00:00 2001 From: Shtyrkin_Egor Date: Wed, 7 Feb 2024 09:25:10 +0400 Subject: [PATCH] =?UTF-8?q?=D0=B3=D0=BE=D1=82=D0=BE=D0=B2=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FishFactory/FormMain.cs | 5 +++-- FishFactory/nlog.config | 2 +- FishFactoryBusinessLogic/BusinessLogic/OrderLogic.cs | 8 ++++++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/FishFactory/FormMain.cs b/FishFactory/FormMain.cs index 4c661cf..b8c0b8f 100644 --- a/FishFactory/FormMain.cs +++ b/FishFactory/FormMain.cs @@ -65,7 +65,6 @@ namespace FishFactory.Forms form.ShowDialog(); } } - private void buttonCreateOrder_Click(object sender, EventArgs e) { var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder)); @@ -84,7 +83,9 @@ namespace FishFactory.Forms try { var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel - { Id = id }); + { + Id = id, + }); if (!operationResult) { throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); diff --git a/FishFactory/nlog.config b/FishFactory/nlog.config index 40d8642..af70d20 100644 --- a/FishFactory/nlog.config +++ b/FishFactory/nlog.config @@ -5,7 +5,7 @@ autoReload="true" internalLogLevel="Info"> - + diff --git a/FishFactoryBusinessLogic/BusinessLogic/OrderLogic.cs b/FishFactoryBusinessLogic/BusinessLogic/OrderLogic.cs index 3df114c..9ea6392 100644 --- a/FishFactoryBusinessLogic/BusinessLogic/OrderLogic.cs +++ b/FishFactoryBusinessLogic/BusinessLogic/OrderLogic.cs @@ -75,7 +75,7 @@ namespace FishFactoryBusinessLogic.BusinessLogic public bool ToNextStatus(OrderBindingModel model, OrderStatus orderStatus) { - CheckModel(model); + CheckModel(model, false); var element = _orderStorage.GetElement(new OrderSearchModel() { Id = model.Id @@ -131,7 +131,11 @@ namespace FishFactoryBusinessLogic.BusinessLogic { throw new ArgumentNullException("Цена заказа должна быть больше 0", nameof(model.Sum)); } - _logger.LogInformation("Canned. CannedId:{CannedId}.Count:{Count}.Sum:{Sum}Id:{Id}", model.CannedId, model.Count, model.Sum, model.Id); + if (model.DateImplement.HasValue && model.DateImplement < model.DateCreate) + { + throw new ArithmeticException($"Дата выдачи заказа {model.DateImplement} должна быть позже даты его создания {model.DateCreate}"); + } + _logger.LogInformation("Canned. CannedId:{CannedId}.Count:{Count}.Sum:{Sum}Id:{Id}", model.CannedId, model.Count, model.Sum, model.Id); } } }