diff --git a/SushiBar/SushiBarFileImplement/Implements/OrderStorage.cs b/SushiBar/SushiBarFileImplement/Implements/OrderStorage.cs index d1e2b75..2f57336 100644 --- a/SushiBar/SushiBarFileImplement/Implements/OrderStorage.cs +++ b/SushiBar/SushiBarFileImplement/Implements/OrderStorage.cs @@ -15,9 +15,7 @@ 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) { @@ -25,13 +23,9 @@ namespace SushiBarFileImplement.Implements { return new(); } - 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(); + return source.Orders.Where(x => + x.Id == model.Id).Select(x => + AttachSushiName(x.GetViewModel)).ToList(); } public OrderViewModel? GetElement(OrderSearchModel model) { @@ -39,8 +33,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 200d951..29483f7 100644 --- a/SushiBar/SushiBarListImplement/Implements/OrderStorage.cs +++ b/SushiBar/SushiBarListImplement/Implements/OrderStorage.cs @@ -25,11 +25,13 @@ 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 || - (model.DateFrom.HasValue && model.DateTo.HasValue && - model.DateFrom < order.DateCreate && order.DateCreate < model.DateTo))) + if (order.Id == model.Id) { result.Add(AttachSushiName(order.GetViewModel)); }