From 450d6d56c2497905ab9488f1b08d3aaf2f025e20 Mon Sep 17 00:00:00 2001 From: bekodeg Date: Sun, 19 May 2024 16:52:54 +0400 Subject: [PATCH] =?UTF-8?q?=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B8=D0=BB=20fi?= =?UTF-8?q?le=20=D0=B8=20list=20implement=20=D0=B7=D0=B0=D0=BA=D0=B0=D0=B7?= =?UTF-8?q?=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Implements/OrderStorage.cs | 18 ++++++++++++------ .../Implements/OrderStorage.cs | 8 +++----- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/SushiBar/SushiBarFileImplement/Implements/OrderStorage.cs b/SushiBar/SushiBarFileImplement/Implements/OrderStorage.cs index 2f57336..d1e2b75 100644 --- a/SushiBar/SushiBarFileImplement/Implements/OrderStorage.cs +++ b/SushiBar/SushiBarFileImplement/Implements/OrderStorage.cs @@ -15,7 +15,9 @@ namespace SushiBarFileImplement.Implements } public List GetFullList() { - return source.Orders.Select(x => AttachSushiName(x.GetViewModel)).ToList(); + return source.Orders + .Select(x => AttachSushiName(x.GetViewModel)) + .ToList(); } public List GetFilteredList(OrderSearchModel model) { @@ -23,9 +25,13 @@ namespace SushiBarFileImplement.Implements { return new(); } - return source.Orders.Where(x => - x.Id == model.Id).Select(x => - AttachSushiName(x.GetViewModel)).ToList(); + return source.Orders + .Where(o => + (model.Id.HasValue && o.Id == model.Id) || + (model.DateFrom.HasValue && model.DateTo.HasValue && + model.DateFrom < o.DateCreate && o.DateCreate < model.DateTo)) + .Select(x => AttachSushiName(x.GetViewModel)) + .ToList(); } public OrderViewModel? GetElement(OrderSearchModel model) { @@ -33,8 +39,8 @@ namespace SushiBarFileImplement.Implements { return null; } - return AttachSushiName(source.Orders.FirstOrDefault(x => - (x.Id == model.Id))?.GetViewModel); + return AttachSushiName(source.Orders + .FirstOrDefault(x => (x.Id == model.Id))?.GetViewModel); } public OrderViewModel? Insert(OrderBindingModel model) { diff --git a/SushiBar/SushiBarListImplement/Implements/OrderStorage.cs b/SushiBar/SushiBarListImplement/Implements/OrderStorage.cs index 29483f7..200d951 100644 --- a/SushiBar/SushiBarListImplement/Implements/OrderStorage.cs +++ b/SushiBar/SushiBarListImplement/Implements/OrderStorage.cs @@ -25,13 +25,11 @@ namespace SushiBarListImplement.Implements public List GetFilteredList(OrderSearchModel model) { var result = new List(); - if (model == null || !model.Id.HasValue) - { - return result; - } foreach (var order in _source.Orders) { - if (order.Id == model.Id) + if (order.Id == model.Id || + (model.DateFrom.HasValue && model.DateTo.HasValue && + model.DateFrom < order.DateCreate && order.DateCreate < model.DateTo))) { result.Add(AttachSushiName(order.GetViewModel)); }