логикa получения списка фильтрованных заказов

This commit is contained in:
VictoriaPresnyakova 2023-03-20 21:07:43 +04:00
parent b99897bc18
commit 3f0071aa7b

View File

@ -8,6 +8,7 @@ using JewelryStoreContracts.SearchModels;
using JewelryStoreContracts.StoragesContracts;
using JewelryStoreContracts.ViewModels;
using JewelryStoreDatabaseImplement.Models;
using Microsoft.EntityFrameworkCore;
namespace JewelryStoreDatabaseImplement.Implements
{
@ -44,14 +45,14 @@ namespace JewelryStoreDatabaseImplement.Implements
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
{
if (!model.Id.HasValue)
if (!model.DateFrom.HasValue || ! model.DateTo.HasValue)
{
return new();
}
using var context = new JewelryStoreDataBase();
return context.Orders.Where(x => x.Id == model.Id).Select(x => x.GetViewModel).ToList();
return context.Orders.Include(x => x.Jewel).Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo).Select(x => x.GetViewModel).ToList();
}
public List<OrderViewModel> GetFullList()