Исправления ошибок
This commit is contained in:
parent
7059604727
commit
1ed3ef3469
CarCenter/CarCenterDataBaseImplement
@ -42,7 +42,7 @@ namespace CarCenterDataBaseImplement.Implemets
|
||||
.ThenInclude(x => x.Sale)
|
||||
.ThenInclude(x => x.PreSaleWorkSale)
|
||||
.ThenInclude(x => x.PreSaleWork)
|
||||
.Include(x => x.Inspection)
|
||||
.Include(x => x.Inspections)
|
||||
.Include(x => x.Manager)
|
||||
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.EmployeeFIO) && x.EmployeeFIO == model.EmployeeFIO) || (model.Id.HasValue && x.Id == model.Id))?
|
||||
.GetViewModel;
|
||||
@ -56,26 +56,12 @@ namespace CarCenterDataBaseImplement.Implemets
|
||||
}
|
||||
using var context = new CarCenterDataBase();
|
||||
|
||||
if (model.DateFrom.HasValue)
|
||||
{
|
||||
return context.Employees
|
||||
.Include(x => x.Sales)
|
||||
.ThenInclude(x => x.Sale)
|
||||
.ThenInclude(x => x.PreSaleWorkSale)
|
||||
.ThenInclude(x => x.PreSaleWork)
|
||||
.Include(x => x.Inspection)
|
||||
.Include(x => x.Manager)
|
||||
.Where(x => x.Specialization >= model.DateFrom && x.Specialization <= model.DateTo && x.ManagerId == model.ManagerId)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
else if (model.ManagerId.HasValue)
|
||||
return context.Employees
|
||||
.Include(x => x.Sales)
|
||||
.ThenInclude(x => x.Sale)
|
||||
.ThenInclude(x => x.PreSaleWorkSale)
|
||||
.ThenInclude(x => x.PreSaleWork)
|
||||
.Include(x => x.Inspection)
|
||||
.Include(x => x.Inspections)
|
||||
.Include(x => x.Manager)
|
||||
.Where(x => x.ManagerId == model.ManagerId)
|
||||
.ToList()
|
||||
@ -87,7 +73,7 @@ namespace CarCenterDataBaseImplement.Implemets
|
||||
.ThenInclude(x => x.Sale)
|
||||
.ThenInclude(x => x.PreSaleWorkSale)
|
||||
.ThenInclude(x => x.PreSaleWork)
|
||||
.Include(x => x.Inspection)
|
||||
.Include(x => x.Inspections)
|
||||
.Include(x => x.Manager)
|
||||
.Where(x => x.EmployeeFIO.Contains(model.EmployeeFIO))
|
||||
.ToList()
|
||||
@ -104,7 +90,7 @@ namespace CarCenterDataBaseImplement.Implemets
|
||||
.ThenInclude(x => x.Sale)
|
||||
.ThenInclude(x => x.PreSaleWorkSale)
|
||||
.ThenInclude(x => x.PreSaleWork)
|
||||
.Include(x => x.Inspection)
|
||||
.Include(x => x.Inspections)
|
||||
.Include(x => x.Manager)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
@ -129,7 +115,7 @@ namespace CarCenterDataBaseImplement.Implemets
|
||||
.ThenInclude(x => x.Sale)
|
||||
.ThenInclude(x => x.PreSaleWorkSale)
|
||||
.ThenInclude(x => x.PreSaleWork)
|
||||
.Include(x => x.Inspection)
|
||||
.Include(x => x.Inspections)
|
||||
.Include(x => x.Manager)
|
||||
.FirstOrDefault(x => x.Id == newEmployee.Id)
|
||||
?.GetViewModel;
|
||||
|
@ -28,7 +28,7 @@ namespace CarCenterDataBaseImplement.Implemets
|
||||
|
||||
public SaleViewModel? GetElement(SaleSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.SaleDate) && !model.Id.HasValue)
|
||||
if (model.SaleDate == default(DateTime) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@ -41,13 +41,13 @@ namespace CarCenterDataBaseImplement.Implemets
|
||||
.Include(x => x.PreSaleWorkSale)
|
||||
.ThenInclude(x => x.PreSaleWork)
|
||||
.Include(x => x.Manager)
|
||||
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.SaleDate) && x.SaleDate == model.SaleDate) || (model.Id.HasValue && x.Id == model.Id))?
|
||||
.FirstOrDefault(x => (model.SaleDate == default(DateTime) && x.SaleDate == model.SaleDate) || (model.Id.HasValue && x.Id == model.Id))?
|
||||
.GetViewModel;
|
||||
}
|
||||
|
||||
public List<SaleViewModel> GetFilteredList(SaleSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.SaleDate) && !model.ManagerId.HasValue)
|
||||
if (model.SaleDate == default(DateTime) && !model.ManagerId.HasValue)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
@ -73,7 +73,7 @@ namespace CarCenterDataBaseImplement.Implemets
|
||||
.Include(x => x.PreSaleWorkSale)
|
||||
.ThenInclude(x => x.PreSaleWork)
|
||||
.Include(x => x.Manager)
|
||||
.Where(x => x.SaleDate.Contains(model.SaleDate))
|
||||
.Where(x => x.SaleDate == model.SaleDate)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ namespace CarCenterDataBaseImplement.Models
|
||||
}
|
||||
|
||||
[ForeignKey("PreSaleWorkId")]
|
||||
public virtual List<Car> Cars { get; set; } = new();
|
||||
public virtual List<Equipment> Equipments { get; set; } = new();
|
||||
|
||||
[ForeignKey("PreSaleWorkId")]
|
||||
public virtual List<PreSaleWorkSale> Sales { get; set; } = new();
|
||||
|
Loading…
x
Reference in New Issue
Block a user