Добавленны поля для поиска по периоду в модель покупки
This commit is contained in:
parent
035fccc42c
commit
f129c4d785
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using CarCenterDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@ -9,5 +10,8 @@ namespace CarCenterContracts.SearchModels
|
||||
public class OrderSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
}
|
||||
public List<IPresaleModel> Presales { get; set; } = new();
|
||||
public DateTime? DateFrom { get; set; }
|
||||
public DateTime? DateTo { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -54,7 +54,35 @@ namespace CarCenterDatabaseImplement.Implements
|
||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||
{
|
||||
using var context = new CarCenterDatabase();
|
||||
if (model.Id.HasValue)
|
||||
|
||||
if (model.DateFrom.HasValue && model.DateTo.HasValue) //для отчета
|
||||
{
|
||||
return context.Orders
|
||||
.Include(x => x.Worker)
|
||||
.Include(x => x.Cars)
|
||||
.Include(x => x.Presales)
|
||||
.ThenInclude(x => x.Presale)
|
||||
.ThenInclude(x => x.Requests)
|
||||
.Include(x => x.Presales)
|
||||
.ThenInclude(x => x.Presale)
|
||||
.ThenInclude(x => x.Bundlings)
|
||||
.ThenInclude(x => x.Bundling)
|
||||
.Where(x => x.PaymentDate >= model.DateFrom && x.PaymentDate <= model.DateTo)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
else if (model.Presales.Count > 0) //для отчета
|
||||
{
|
||||
return context.Orders
|
||||
.Include(x => x.Worker)
|
||||
.Include(x => x.Cars)
|
||||
.Include(x => x.Presales)
|
||||
.ThenInclude(x => x.Presale)
|
||||
.Where(x => x.OrderPresales.Any(p => model.Presales.Any(presale => p.Value == presale)))
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
else if (model.Id.HasValue)
|
||||
{
|
||||
return context.Orders
|
||||
.Include(x => x.Worker)
|
||||
|
Loading…
x
Reference in New Issue
Block a user