dop logic

This commit is contained in:
parap 2023-05-02 22:29:10 +04:00
parent f396af1eb9
commit 7630dabb9e
2 changed files with 9 additions and 2 deletions

View File

@ -39,7 +39,11 @@ namespace PizzeriaListImplement.Implements
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) &&
(!model.DateTo.HasValue || order.DateCreate <= model.DateTo)
)
{
OrderViewModel viewModel = order.GetViewModel;
viewModel.PizzaName = _pizzaStorage.GetElement(new PizzaSearchModel { Id = order.PizzaId }).PizzaName;

View File

@ -23,7 +23,10 @@ namespace PizzeriaFileImplement.Implements
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
{
return source.Orders
.Where(x => (model.Id.HasValue && 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 => x.GetViewModel)
.ToList();
}