Karamushko M.K lab4_base #5

Closed
maxKarme wants to merge 6 commits from lab4_base into lab3_base
2 changed files with 9 additions and 2 deletions
Showing only changes of commit 7630dabb9e - Show all commits

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();
}