From 7630dabb9e72ca766df562441738277d61336080 Mon Sep 17 00:00:00 2001 From: parap Date: Tue, 2 May 2023 22:29:10 +0400 Subject: [PATCH] dop logic --- Pizzeria/PizzeriaListImplement/Implements/OrderStorage.cs | 6 +++++- .../PizzeriaShopFileImplement/Implements/OrderStorage.cs | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Pizzeria/PizzeriaListImplement/Implements/OrderStorage.cs b/Pizzeria/PizzeriaListImplement/Implements/OrderStorage.cs index 2e033c4..6444065 100644 --- a/Pizzeria/PizzeriaListImplement/Implements/OrderStorage.cs +++ b/Pizzeria/PizzeriaListImplement/Implements/OrderStorage.cs @@ -39,7 +39,11 @@ namespace PizzeriaListImplement.Implements foreach (var order in _source.Orders) { - if (model.Id.HasValue && order.Id == model.Id) + if ( + (!model.Id.HasValue || order.Id == model.Id) && + (!model.DateFrom.HasValue || order.DateCreate >= model.DateFrom) && + (!model.DateTo.HasValue || order.DateCreate <= model.DateTo) + ) { OrderViewModel viewModel = order.GetViewModel; viewModel.PizzaName = _pizzaStorage.GetElement(new PizzaSearchModel { Id = order.PizzaId }).PizzaName; diff --git a/Pizzeria/PizzeriaShopFileImplement/Implements/OrderStorage.cs b/Pizzeria/PizzeriaShopFileImplement/Implements/OrderStorage.cs index 9c695a3..92895f0 100644 --- a/Pizzeria/PizzeriaShopFileImplement/Implements/OrderStorage.cs +++ b/Pizzeria/PizzeriaShopFileImplement/Implements/OrderStorage.cs @@ -23,7 +23,10 @@ namespace PizzeriaFileImplement.Implements public List GetFilteredList(OrderSearchModel model) { return source.Orders - .Where(x => (model.Id.HasValue && x.Id == model.Id)) + .Where(x => + (!model.Id.HasValue || x.Id == model.Id) && + (!model.DateFrom.HasValue || x.DateCreate >= model.DateFrom) && + (!model.DateTo.HasValue || x.DateCreate <= model.DateTo)) .Select(x => x.GetViewModel) .ToList(); }