lab5 alpha3

This commit is contained in:
DeerElk 2024-05-05 05:50:26 +04:00
parent 94d670186c
commit cbdc5e691b
2 changed files with 28 additions and 34 deletions

View File

@ -18,22 +18,19 @@ namespace ConfectioneryFileImplement.Implements
.Select(x => AccessPastryStorage(x.GetViewModel)) .Select(x => AccessPastryStorage(x.GetViewModel))
.ToList(); .ToList();
} }
public List<OrderViewModel> GetFilteredList(OrderSearchModel model) public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
{ {
return source.Orders return source.Orders
.Where(x => ( .Where(x => (
(!model.Id.HasValue || x.Id == model.Id) && (!model.Id.HasValue || x.Id == model.Id) &&
(!model.DateFrom.HasValue || x.DateCreate >= (!model.DateFrom.HasValue || x.DateCreate >= model.DateFrom) &&
model.DateFrom) && (!model.DateTo.HasValue || (!model.DateTo.HasValue || x.DateCreate <= model.DateTo)
x.DateCreate <= model.DateTo) && )
(!model.ClientId.HasValue || )
x.ClientId == model.ClientId) .Select(x => AccessPastryStorage(x.GetViewModel))
) .ToList();
) }
.Select(x => AccessPastryStorage(x.GetViewModel)) public OrderViewModel? GetElement(OrderSearchModel model)
.ToList();
}
public OrderViewModel? GetElement(OrderSearchModel model)
{ {
if (!model.Id.HasValue) if (!model.Id.HasValue)
{ {

View File

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