From d193af6f05c2df3a91e81f670e0d84926ad38ff8 Mon Sep 17 00:00:00 2001 From: prodigygirl Date: Sun, 9 Apr 2023 13:36:54 +0400 Subject: [PATCH] merge --- .../Implements/OrderStorage.cs | 10 +++++++- .../Implements/OrderStorage.cs | 14 +++++++++-- .../Implements/OrderStorage.cs | 23 ++++++++++++++++--- 3 files changed, 41 insertions(+), 6 deletions(-) diff --git a/FurnitureAssembly/FurnitureAssemFileImplement/Implements/OrderStorage.cs b/FurnitureAssembly/FurnitureAssemFileImplement/Implements/OrderStorage.cs index 3b5d489..ffec323 100644 --- a/FurnitureAssembly/FurnitureAssemFileImplement/Implements/OrderStorage.cs +++ b/FurnitureAssembly/FurnitureAssemFileImplement/Implements/OrderStorage.cs @@ -31,8 +31,16 @@ namespace FurnitureAssemFileImplement.Implements { 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 || model.ClientId == x.ClientId) + .Where(x => !(((model.DateFrom.HasValue) && (model.DateTo.HasValue)) && !(model.DateFrom <= x.DateCreate && x.DateCreate <= model.DateTo) || + (model.ClientId.HasValue) && !(x.ClientId.Equals(model.ClientId)))) .Select(x => GetOrderViewModel(x)) .ToList(); } diff --git a/FurnitureAssembly/FurnitureAssemblyDatabaseImplement/Implements/OrderStorage.cs b/FurnitureAssembly/FurnitureAssemblyDatabaseImplement/Implements/OrderStorage.cs index 1ecd031..060ef69 100644 --- a/FurnitureAssembly/FurnitureAssemblyDatabaseImplement/Implements/OrderStorage.cs +++ b/FurnitureAssembly/FurnitureAssemblyDatabaseImplement/Implements/OrderStorage.cs @@ -29,15 +29,25 @@ namespace FurnitureAssemblyDatabaseImplement.Implements public List GetFilteredList(OrderSearchModel model) { - if (!model.Id.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue && !model.ClientId.HasValue) + if (!model.Id.HasValue && (!model.DateFrom.HasValue || !model.DateTo.HasValue) && !model.ClientId.HasValue) { return new(); } using var context = new FurnitureAssemblyDatabase(); + if (model.Id.HasValue) + { + return context.Orders + .Include(x => x.Furniture).Include(x => x.Client) + .Where(x => x.Id == model.Id) + .Select(x => x.GetViewModel) + .ToList(); + } + return context.Orders .Include(x => x.Furniture) .Include(x => x.Client) - .Where(x => x.Id == model.Id || model.DateFrom <= x.DateCreate && x.DateCreate <= model.DateTo || model.ClientId == x.ClientId) + .Where(x => !(((model.DateFrom.HasValue) && (model.DateTo.HasValue)) && !(model.DateFrom <= x.DateCreate && x.DateCreate <= model.DateTo) || + (model.ClientId.HasValue) && !(x.ClientId.Equals(model.ClientId)))) .Select(x => x.GetViewModel) .ToList(); } diff --git a/FurnitureAssembly/FurnitureAssemblyListImplement/Implements/OrderStorage.cs b/FurnitureAssembly/FurnitureAssemblyListImplement/Implements/OrderStorage.cs index 91d2476..8942079 100644 --- a/FurnitureAssembly/FurnitureAssemblyListImplement/Implements/OrderStorage.cs +++ b/FurnitureAssembly/FurnitureAssemblyListImplement/Implements/OrderStorage.cs @@ -51,16 +51,33 @@ namespace FurnitureAssemblyListImplement.Implements public List GetFilteredList(OrderSearchModel model) { + if (!model.Id.HasValue && (!model.DateFrom.HasValue || !model.DateTo.HasValue)) + { + 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 (order.Id.Equals(model.Id) || model.DateFrom <= order.DateCreate && order.DateCreate <= model.DateTo || order.ClientId.Equals(model.ClientId)) + if (!(((model.DateFrom.HasValue) && (model.DateTo.HasValue)) && !(model.DateFrom <= order.DateCreate && order.DateCreate <= model.DateTo) || + (model.ClientId.HasValue) && !(order.ClientId.Equals(model.ClientId)))) { result.Add(GetOrderViewModel(order)); } + } - return result; + return result; } public List GetFullList()