From 9d7b36ec1db0f7ffa93e28080dcdf6abfe2c10a6 Mon Sep 17 00:00:00 2001 From: prodigygirl Date: Sun, 9 Apr 2023 12:27:31 +0400 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=BF=D0=BE=20=D1=84=D0=B8=D0=BB?= =?UTF-8?q?=D1=8C=D1=82=D1=80=D0=B0=D1=86=D0=B8=D0=B8=20=D0=B7=D0=B0=D0=BA?= =?UTF-8?q?=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 | 11 +++++++-- .../Implements/OrderStorage.cs | 19 +++++++++++---- .../Implements/OrderStorage.cs | 23 +++++++++++++++---- 3 files changed, 42 insertions(+), 11 deletions(-) diff --git a/FurnitureAssembly/FurnitureAssemFileImplement/Implements/OrderStorage.cs b/FurnitureAssembly/FurnitureAssemFileImplement/Implements/OrderStorage.cs index f7b0e33..9d463d5 100644 --- a/FurnitureAssembly/FurnitureAssemFileImplement/Implements/OrderStorage.cs +++ b/FurnitureAssembly/FurnitureAssemFileImplement/Implements/OrderStorage.cs @@ -27,12 +27,19 @@ namespace FurnitureAssemFileImplement.Implements public List GetFilteredList(OrderSearchModel model) { - if (!model.Id.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue) + if (!model.Id.HasValue && (!model.DateFrom.HasValue || !model.DateTo.HasValue)) { return new(); } + if (model.Id.HasValue) + { + return source.Orders + .Where(x => x.Id.Equals(model.Id)) + .Select(x => GetOrderViewModel(x)) + .ToList(); + } return source.Orders - .Where(x => x.Id.Equals(model.Id) || model.DateFrom <= x.DateCreate && x.DateCreate <= model.DateTo) + .Where(x => model.DateFrom <= x.DateCreate && x.DateCreate <= model.DateTo) .Select(x => GetOrderViewModel(x)) .ToList(); } diff --git a/FurnitureAssembly/FurnitureAssemblyDatabaseImplement/Implements/OrderStorage.cs b/FurnitureAssembly/FurnitureAssemblyDatabaseImplement/Implements/OrderStorage.cs index 71a32e6..18ab0b3 100644 --- a/FurnitureAssembly/FurnitureAssemblyDatabaseImplement/Implements/OrderStorage.cs +++ b/FurnitureAssembly/FurnitureAssemblyDatabaseImplement/Implements/OrderStorage.cs @@ -29,16 +29,25 @@ namespace FurnitureAssemblyDatabaseImplement.Implements public List GetFilteredList(OrderSearchModel model) { - if (!model.Id.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue) + if (!model.Id.HasValue && (!model.DateFrom.HasValue || !model.DateTo.HasValue)) { return new(); } using var context = new FurnitureAssemblyDatabase(); + if (model.Id.HasValue) + { + return context.Orders + .Include(x => x.Furniture) + .Where(x => x.Id == model.Id) + .Select(x => x.GetViewModel) + .ToList(); + } + return context.Orders - .Include(x => x.Furniture) - .Where(x => x.Id == model.Id || model.DateFrom <= x.DateCreate && x.DateCreate <= model.DateTo) - .Select(x => x.GetViewModel) - .ToList(); + .Include(x => x.Furniture) + .Where(x => model.DateFrom <= x.DateCreate && x.DateCreate <= model.DateTo) + .Select(x => x.GetViewModel) + .ToList(); } public List GetFullList() diff --git a/FurnitureAssembly/FurnitureAssemblyListImplement/Implements/OrderStorage.cs b/FurnitureAssembly/FurnitureAssemblyListImplement/Implements/OrderStorage.cs index fa19031..42bb163 100644 --- a/FurnitureAssembly/FurnitureAssemblyListImplement/Implements/OrderStorage.cs +++ b/FurnitureAssembly/FurnitureAssemblyListImplement/Implements/OrderStorage.cs @@ -51,11 +51,26 @@ namespace FurnitureAssemblyListImplement.Implements public List GetFilteredList(OrderSearchModel model) { - var result = new List(); - - foreach (var order in _source.Orders) + if (!model.Id.HasValue && (!model.DateFrom.HasValue || !model.DateTo.HasValue)) { - if (order.Id.Equals(model.Id) || model.DateFrom <= order.DateCreate && order.DateCreate <= model.DateTo) + return new(); + } + var result = new List(); + if (model.Id.HasValue) + { + foreach (var order in _source.Orders) + { + if (order.Id.Equals(model.Id)) + { + result.Add(GetOrderViewModel(order)); + break; + } + } + return result; + } + foreach (var order in _source.Orders) + { + if (model.DateFrom <= order.DateCreate && order.DateCreate <= model.DateTo) { result.Add(GetOrderViewModel(order)); }