Изменение получения отфильтрованного списка заказа

This commit is contained in:
Володя 2023-04-19 18:11:43 +03:00
parent 00fd7a1f50
commit 5342ad9663
3 changed files with 6 additions and 6 deletions

View File

@ -35,14 +35,14 @@ namespace AutomobilePlantListImplement.Implements
{
var result = new List<OrderViewModel>();
if (!model.Id.HasValue)
if (model is null)
{
return result;
}
foreach (var order in _source.Orders)
{
if (model.Id.HasValue && order.Id == model.Id)
if (order.DateCreate > model.DateFrom && order.DateCreate < model.DateTo)
{
result.Add(order.GetViewModel);
}

View File

@ -24,13 +24,13 @@ namespace AutomobilePlantDataBaseImplements.Implements
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
{
if (model.Id.HasValue)
if (model is null)
{
return new();
}
using var context = new AutoPlantDataBase();
return context.Orders
.Where(x => x.Id == model.Id)
.Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo)
.ToList()
.Select(x => x.GetViewModel)
.ToList();

View File

@ -45,12 +45,12 @@ namespace AutomomilePlantFileImplement.Implements
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
{
if (!model.Id.HasValue)
if (model is null)
{
return new();
}
return source.Orders
.Where(x => x.Id == model.Id)
.Where(x => x.DateCreate > model.DateFrom && x.DateCreate < model.DateTo)
.Select(x => x.GetViewModel)
.ToList();
}