Вроде усё

This commit is contained in:
Marselchi 2024-04-30 23:05:36 +04:00
parent f129c4d785
commit 79fe8e39c3
4 changed files with 30 additions and 4 deletions

View File

@ -10,5 +10,7 @@ namespace CarCenterContracts.SearchModels
{
public int? Id { get; set; }
public long? VINnumber { get; set; }
}
public DateTime? DateFrom { get; set; }
public DateTime? DateTo { get; set; }
}
}

View File

@ -11,6 +11,7 @@ namespace CarCenterContracts.SearchModels
{
public int? Id { get; set; }
public List<IPresaleModel> Presales { get; set; } = new();
public List<ICarModel> Cars { get; set; } = new();
public DateTime? DateFrom { get; set; }
public DateTime? DateTo { get; set; }
}

View File

@ -29,7 +29,19 @@ namespace CarCenterDatabaseImplement.Implements
public List<CarViewModel> GetFilteredList(CarSearchModel model)
{
using var context = new CarCenterDatabase();
if (model.Id.HasValue)
if (model.DateFrom.HasValue && model.DateTo.HasValue)
{
return context.Cars
.Include(x => x.Bundlings)
.ThenInclude(x => x.Bundling)
.Include(x => x.Feature)
.Include(x => x.Order)
.Include(x => x.Storekeeper)
.Where(x => x.Order.PaymentDate >= model.DateFrom && x.Order.PaymentDate <= model.DateTo)
.Select(x => x.GetViewModel)
.ToList();
}
else if (model.Id.HasValue)
{
return context.Cars
.Include(x => x.Bundlings)

View File

@ -55,7 +55,7 @@ namespace CarCenterDatabaseImplement.Implements
{
using var context = new CarCenterDatabase();
if (model.DateFrom.HasValue && model.DateTo.HasValue) //для отчета
if (model.DateFrom.HasValue && model.DateTo.HasValue) //для списка Сагиров
{
return context.Orders
.Include(x => x.Worker)
@ -71,7 +71,7 @@ namespace CarCenterDatabaseImplement.Implements
.Select(x => x.GetViewModel)
.ToList();
}
else if (model.Presales.Count > 0) //для отчета
else if (model.Presales.Count > 0) //для отчета Сагиров
{
return context.Orders
.Include(x => x.Worker)
@ -82,6 +82,17 @@ namespace CarCenterDatabaseImplement.Implements
.Select(x => x.GetViewModel)
.ToList();
}
else if (model.Cars.Count > 0) //для отчета Малафеев
{
return context.Orders
.Include(x => x.Worker)
.Include(x => x.Cars)
.Include(x => x.Presales)
.ThenInclude(x => x.Presale)
.Where(x => x.Cars.Any(car => model.Cars.Any(searchCar => car.Id == searchCar.Id)))
.Select(x => x.GetViewModel)
.ToList();
}
else if (model.Id.HasValue)
{
return context.Orders