From fb5507c55c76b727223581673a9a3d101162af62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BD=D0=B8=D1=8F=D1=80=20=D0=90=D0=B3=D0=BB?= =?UTF-8?q?=D0=B8=D1=83=D0=BB=D0=BB=D0=BE=D0=B2?= Date: Mon, 6 Mar 2023 17:14:11 +0400 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=B2=D0=BE=D0=B7=D0=BC=D0=BE=D0=B6=D0=BD=D0=BE?= =?UTF-8?q?=D1=81=D1=82=D1=8C=20=D0=BE=D0=B1=D0=BD=D0=BE=D0=B2=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20=D0=B8=D1=81=D0=BF=D0=BE=D0=BB=D0=BD=D0=B8=D1=82=D0=B5?= =?UTF-8?q?=D0=BB=D1=8F=20=D0=B4=D0=BB=D1=8F=20=D0=B7=D0=B0=D0=BA=D0=B0?= =?UTF-8?q?=D0=B7=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ConfectionaryBusinessLogic/OrderLogic.cs | 7 ++++--- ConfectionaryBusinessLogic/WorkModeling.cs | 9 +++++---- ConfectionaryFileImplement/Order.cs | 5 +++-- ConfectionaryListImplement/Order.cs | 1 + ConfectioneryDatabaseImplement/Order.cs | 1 + ConfectioneryDatabaseImplement/OrderStorage.cs | 6 +++++- 6 files changed, 19 insertions(+), 10 deletions(-) diff --git a/ConfectionaryBusinessLogic/OrderLogic.cs b/ConfectionaryBusinessLogic/OrderLogic.cs index f079f58..45bd78c 100644 --- a/ConfectionaryBusinessLogic/OrderLogic.cs +++ b/ConfectionaryBusinessLogic/OrderLogic.cs @@ -90,16 +90,17 @@ namespace ConfectioneryBusinessLogic.BusinessLogics } if ((int)vmodel.Status + 1 != (int)orderStatus) { - throw new ArgumentException($"Попытка перевести заказ не в следующий статус: " + + throw new InvalidOperationException($"Попытка перевести заказ не в следующий статус: " + $"Текущий статус: {vmodel.Status} \n" + $"Планируемый статус: {orderStatus} \n" + - $"Доступный статус: {(OrderStatus)((int)vmodel.Status + 1)}", - nameof(vmodel)); + $"Доступный статус: {(OrderStatus)((int)vmodel.Status + 1)}"); } model.Status = orderStatus; model.DateCreate = vmodel.DateCreate; if (model.DateImplement == null) model.DateImplement = vmodel.DateImplement; + if (vmodel.ImplementerId.HasValue) + model.ImplementerId = vmodel.ImplementerId; model.PastryId = vmodel.PastryId; model.Sum = vmodel.Sum; model.Count= vmodel.Count; diff --git a/ConfectionaryBusinessLogic/WorkModeling.cs b/ConfectionaryBusinessLogic/WorkModeling.cs index f19fafe..0104a6d 100644 --- a/ConfectionaryBusinessLogic/WorkModeling.cs +++ b/ConfectionaryBusinessLogic/WorkModeling.cs @@ -2,6 +2,7 @@ using ConfectioneryContracts.BusinessLogicsContracts; using ConfectioneryContracts.SearchModels; using ConfectioneryContracts.ViewModels; +using ConfectioneryDataModels.Enums; using Microsoft.Extensions.Logging; using System; using System.Collections.Generic; @@ -34,7 +35,7 @@ namespace ConfectioneryBusinessLogic _logger.LogWarning("DoWork. Implementers is null"); return; } - var orders = _orderLogic.ReadList(new OrderSearchModel { /*Status = OrderStatus.Принят*/ }); + var orders = _orderLogic.ReadList(new OrderSearchModel { Status = OrderStatus.Принят }); if (orders == null || orders.Count == 0) { _logger.LogWarning("DoWork. Orders is null or empty"); @@ -71,7 +72,7 @@ namespace ConfectioneryBusinessLogic _orderLogic.TakeOrderInWork(new OrderBindingModel { Id = order.Id, - // ImplementerId = implementer.Id + ImplementerId = implementer.Id }); // делаем работу Thread.Sleep(implementer.WorkExperience * _rnd.Next(100, 1000) * order.Count); @@ -113,8 +114,8 @@ namespace ConfectioneryBusinessLogic { var runOrder = await Task.Run(() => _orderLogic.ReadElement(new OrderSearchModel { - // ImplementerId = implementer.Id, - // Status = OrderStatus.Выполняется + ImplementerId = implementer.Id, + Status = OrderStatus.Выполняется })); if (runOrder == null) { diff --git a/ConfectionaryFileImplement/Order.cs b/ConfectionaryFileImplement/Order.cs index cc960c8..2953eac 100644 --- a/ConfectionaryFileImplement/Order.cs +++ b/ConfectionaryFileImplement/Order.cs @@ -41,7 +41,7 @@ namespace ConfectioneryFileImplement.Models Status = model.Status, DateCreate = model.DateCreate, DateImplement = model.DateImplement, - ImplementerId = model.ImplementerId, + ImplementerId = model.ImplementerId, Id = model.Id, }; } @@ -77,8 +77,9 @@ namespace ConfectioneryFileImplement.Models Sum = model.Sum; Status = model.Status; DateCreate = model.DateCreate; + ImplementerId = model.ImplementerId; DateImplement = model.DateImplement; - Id = model.Id; + Id = model.Id; } public OrderViewModel GetViewModel => new() { diff --git a/ConfectionaryListImplement/Order.cs b/ConfectionaryListImplement/Order.cs index 85a9423..539716f 100644 --- a/ConfectionaryListImplement/Order.cs +++ b/ConfectionaryListImplement/Order.cs @@ -56,6 +56,7 @@ namespace ConfectioneryListImplement.Models Status = model.Status; DateCreate = model.DateCreate; DateImplement = model.DateImplement; + ImplementerId = model.ImplementerId; Id = model.Id; } public OrderViewModel GetViewModel => new() diff --git a/ConfectioneryDatabaseImplement/Order.cs b/ConfectioneryDatabaseImplement/Order.cs index 1370bd8..e565c25 100644 --- a/ConfectioneryDatabaseImplement/Order.cs +++ b/ConfectioneryDatabaseImplement/Order.cs @@ -78,6 +78,7 @@ namespace ConfectioneryDatabaseImplement.Models Status = model.Status; DateCreate = model.DateCreate; DateImplement = model.DateImplement; + ImplementerId = model.ImplementerId; Id = model.Id; } public OrderViewModel GetViewModel diff --git a/ConfectioneryDatabaseImplement/OrderStorage.cs b/ConfectioneryDatabaseImplement/OrderStorage.cs index 7e95ba8..d00fcca 100644 --- a/ConfectioneryDatabaseImplement/OrderStorage.cs +++ b/ConfectioneryDatabaseImplement/OrderStorage.cs @@ -56,13 +56,17 @@ namespace ConfectioneryDatabaseImplement.Implements .Where(x => model.DateFrom <= x.DateCreate.Date && x.DateCreate.Date <= model.DateTo); } + else if (model.Status.HasValue && model.ImplementerId.HasValue) + { + queryWhere = context.Orders.Where(x => x.ImplementerId == model.ImplementerId && x.Status == model.Status); + } else if (model.Status.HasValue) { queryWhere = context.Orders.Where(x => x.Status == model.Status); } else if (model.ClientId.HasValue) { - queryWhere = context.Orders.Where(x => x.Client.Id == model.ClientId); + queryWhere = context.Orders.Where(x => x.ClientId == model.ClientId); } else {