Compare commits

...

2 Commits

Author SHA1 Message Date
9106c350e0 lab4.. 2024-05-05 05:45:08 +04:00
e62bd8a33c lab4. 2024-05-05 05:34:17 +04:00
2 changed files with 11 additions and 12 deletions

View File

@ -20,12 +20,13 @@ namespace ConfectioneryFileImplement.Implements
}
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
{
if (!model.Id.HasValue)
{
return new();
}
return source.Orders
.Where(x => 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 => AccessPastryStorage(x.GetViewModel))
.ToList();
}

View File

@ -24,13 +24,11 @@ namespace ConfectioneryListImplement.Implements
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
{
var result = new List<OrderViewModel>();
if (!model.Id.HasValue)
{
return result;
}
foreach (var order in _source.Orders)
{
if (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))
{
result.Add(AccessPastryStorage(order.GetViewModel));
}