database implements layers

This commit is contained in:
MaxKarme 2023-03-24 21:34:48 +04:00
parent b3db89edd4
commit f41a3493b1

View File

@ -22,7 +22,12 @@ namespace PizzeriaDatabaseImplement.Implements
{ {
using var context = new PizzeriaDatabase(); using var context = new PizzeriaDatabase();
return context.Orders return context.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) .Select(x => x.GetViewModel)
.ToList(); .ToList();
} }