From b365a146d34f7efb9f333346d1b51fa3a674faad Mon Sep 17 00:00:00 2001 From: frog24 Date: Sat, 18 May 2024 17:56:58 +0400 Subject: [PATCH] =?UTF-8?q?=D0=BA=D0=BE=D0=BD=D1=84=D0=BB=D0=B8=D0=BA?= =?UTF-8?q?=D1=82=D1=8B=20=D0=BC=D0=BE=D0=B8=20=D0=BA=D0=BE=D0=BD=D1=84?= =?UTF-8?q?=D0=BB=D0=B8=D0=BA=D1=82=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Implements/OrderStorage.cs | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/ComputersShop/ComputersShopDatabaseImplements/Implements/OrderStorage.cs b/ComputersShop/ComputersShopDatabaseImplements/Implements/OrderStorage.cs index 0c51284..0b2f806 100644 --- a/ComputersShop/ComputersShopDatabaseImplements/Implements/OrderStorage.cs +++ b/ComputersShop/ComputersShopDatabaseImplements/Implements/OrderStorage.cs @@ -12,7 +12,7 @@ using System.Threading.Tasks; namespace ComputersShopDatabaseImplements.Implements { - public class OrderStorage: IOrderStorage + public class OrderStorage : IOrderStorage { public OrderViewModel? GetElement(OrderSearchModel model) { @@ -22,19 +22,19 @@ namespace ComputersShopDatabaseImplements.Implements } using var context = new ComputersShopDatabase(); return context.Orders - .Include(x => x.Computer) - .Include(x => x.Client) - .Include(x => x.Implementer) - .FirstOrDefault(x => - (model.Status == null || model.Status != null && model.Status.Equals(x.Status)) && - (model.ImplementerId.HasValue && x.ImplementerId == model.ImplementerId) || - (model.Id.HasValue && x.Id == model.Id))? - .GetViewModel; + .Include(x => x.Computer) + .Include(x => x.Client) + .Include(x => x.Implementer) + .FirstOrDefault(x => + (model.Status == null || model.Status != null && model.Status.Equals(x.Status)) && + (model.ImplementerId.HasValue && x.ImplementerId == model.ImplementerId) || + (model.Id.HasValue && x.Id == model.Id))? + .GetViewModel; } public List GetFiltredList(OrderSearchModel model) { - if (!model.DateFrom.HasValue && !model.ClientId.HasValue && !model.Id.HasValue && !model.Status.HasValue) - { + if (!model.DateFrom.HasValue && !model.ClientId.HasValue && !model.Id.HasValue && !model.Status.HasValue) + { return new(); } using var context = new ComputersShopDatabase(); @@ -42,15 +42,15 @@ namespace ComputersShopDatabaseImplements.Implements { return context.Orders.Include(x => x.Computer).Include(x => x.Client).Include(x => x.Implementer).Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo).Select(x => x.GetViewModel).ToList(); } - if (model.ClientId.HasValue) - { - return context.Orders.Include(x => x.Computer).Include(x => x.Client).Include(x => x.Implementer).Where(x => x.ClientId == model.ClientId).Select(x => x.GetViewModel).ToList(); - } - if (model.Status.HasValue) + if (model.ClientId.HasValue) + { + return context.Orders.Include(x => x.Computer).Include(x => x.Client).Include(x => x.Implementer).Where(x => x.ClientId == model.ClientId).Select(x => x.GetViewModel).ToList(); + } + if (model.Status.HasValue) { return context.Orders.Include(x => x.Computer).Include(x => x.Client).Include(x => x.Implementer).Where(x => x.Status.Equals(model.Status)).Select(x => x.GetViewModel).ToList(); - } - return context.Orders.Where(x => x.Id == model.Id).Include(x => x.Computer).Include(x => x.Client).Include(x => x.Implementer).Select(x => x.GetViewModel).ToList(); + } + return context.Orders.Where(x => x.Id == model.Id).Include(x => x.Computer).Include(x => x.Client).Include(x => x.Implementer).Select(x => x.GetViewModel).ToList(); } public List GetFullList() { @@ -94,4 +94,4 @@ namespace ComputersShopDatabaseImplements.Implements return null; } } -} +} \ No newline at end of file