From b38577fc3afe8c36daf6b68c023135c341f97b9e Mon Sep 17 00:00:00 2001 From: "ityurner02@mail.ru" Date: Sun, 16 Apr 2023 22:47:33 +0400 Subject: [PATCH] =?UTF-8?q?=D0=BB=D0=BE=D0=B3=D0=B3=D0=B5=D1=80=20=D0=B2?= =?UTF-8?q?=D0=B8=D0=B4=D0=B8=D1=82=20=D1=80=D0=B5=D0=B0=D0=BB=D1=8C=D0=BD?= =?UTF-8?q?=D0=BE=D0=B5=20=D0=BA=D0=BE=D0=BB=D0=B8=D1=87=D0=B5=D1=81=D1=82?= =?UTF-8?q?=D0=B2=D0=BE=20=D0=B7=D0=B0=D0=BA=D0=B0=D0=B7=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Implements/OrderStorage.cs | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/PlumbingRepair/PlumbingRepairDatabaseImplement/Implements/OrderStorage.cs b/PlumbingRepair/PlumbingRepairDatabaseImplement/Implements/OrderStorage.cs index 9842a92..f49d274 100644 --- a/PlumbingRepair/PlumbingRepairDatabaseImplement/Implements/OrderStorage.cs +++ b/PlumbingRepair/PlumbingRepairDatabaseImplement/Implements/OrderStorage.cs @@ -44,7 +44,7 @@ namespace PlumbingRepairDatabaseImplement.Implements .Select(x => x.GetViewModel) .ToList(); } - else if (model.ClientId.HasValue) + else if (model.ClientId.HasValue) { return context.Orders .Include(x => x.Work) @@ -64,9 +64,14 @@ namespace PlumbingRepairDatabaseImplement.Implements .Select(x => x.GetViewModel) .ToList(); } - - return new(); - } + return context.Orders + .Include(x => x.Work) + .Include(x => x.Client) + .Include(x => x.Implementer) + .Where(x => model.Status == x.Status) + .Select(x => x.GetViewModel) + .ToList(); + } public OrderViewModel? GetElement(OrderSearchModel model) { @@ -81,9 +86,10 @@ namespace PlumbingRepairDatabaseImplement.Implements .Include(x => x.Work) .Include(x => x.Client) .Include(x => x.Implementer) - .FirstOrDefault(x => (!model.ImplementerId.HasValue || x.ImplementerId == model.ImplementerId) && - (!model.Status.HasValue || x.Status == model.Status) && - (!model.Id.HasValue || x.Id == model.Id))?.GetViewModel; + .FirstOrDefault(x => (model.Status == null || model.Status != null && model.Status == x.Status) && + model.ImplementerId.HasValue && x.ImplementerId == model.ImplementerId || + model.Id.HasValue && x.Id == model.Id) + ?.GetViewModel; } public OrderViewModel? Insert(OrderBindingModel model)