diff --git a/Confectionery/ConfectioneryDatabaseImplement/OrderStorage.cs b/Confectionery/ConfectioneryDatabaseImplement/OrderStorage.cs index f47bf75..1b26475 100644 --- a/Confectionery/ConfectioneryDatabaseImplement/OrderStorage.cs +++ b/Confectionery/ConfectioneryDatabaseImplement/OrderStorage.cs @@ -23,8 +23,11 @@ namespace ConfectioneryDatabaseImplement.Implements public List GetFilteredList(OrderSearchModel model) { using var context = new ConfectioneryDatabase(); - var result = context.Orders.Include(x => x.Pastry).Select(x => x.GetViewModel).ToList(); - return result; + if (model.DateFrom.HasValue) + { + return context.Orders.Include(x => x.Pastry).Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo).Select(x => x.GetViewModel).ToList(); + } + return context.Orders.Include(x => x.Pastry).Where(x => x.Id == model.Id).Select(x => x.GetViewModel).ToList(); } public OrderViewModel? GetElement(OrderSearchModel model)