Balberova D.N. LabWork04Hard #8
@ -21,14 +21,14 @@ namespace SushiBarFileImplement.Implements
|
||||
|
||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
if (!model.Id.HasValue && !model.DateFrom.HasValue)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
if (model.DateFrom.HasValue)
|
||||
{
|
||||
return source.Orders
|
||||
.Where(x => x.Id.Equals(model.Id) && x.DateCreate >= model.DateFrom)
|
||||
.Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo)
|
||||
.Select(x => GetViewModel(x))
|
||||
.ToList();
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ namespace SushiBarListImplement.Implements
|
||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||
{
|
||||
var result = new List<OrderViewModel>();
|
||||
if (!model.Id.HasValue)
|
||||
if (!model.Id.HasValue && !model.DateFrom.HasValue)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
@ -33,7 +33,7 @@ namespace SushiBarListImplement.Implements
|
||||
{
|
||||
foreach (var order in _source.Orders)
|
||||
{
|
||||
if (order.Id == model.Id && order.DateCreate >= model.DateFrom)
|
||||
if (order.DateCreate >= model.DateFrom && order.DateCreate <= model.DateTo)
|
||||
{
|
||||
result.Add(GetViewModel(order));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user