Merge branch 'LabWork06_Base' into LabWork07_Base

This commit is contained in:
Павел Сорокин 2023-04-25 15:51:02 +04:00
commit a4216eba08

View File

@ -70,53 +70,37 @@ namespace ShipyardDataBaseImplement.Implements
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
{
using var context = new ShipyardDataBase();
if (model.Id.HasValue)
if (model.DateFrom.HasValue && model.DateTo.HasValue)
{
return context.Orders
.Include(x => x.Ship)
.Include(x => x.Client)
.Include(x => x.Implementer)
.Where(x => x.Id == model.Id)
.Select(x => x.GetViewModel)
.ToList();
}
else if (model.DateFrom != null && model.DateTo != null)
{
return context.Orders
.Include(x => x.Ship)
.Include(x => x.Client)
.Include(x => x.Implementer)
.Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo)
.Select(x => x.GetViewModel)
.ToList();
.Include(x => x.Ship)
.Include(x => x.Client).Include(x => x.Implementer)
.Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo)
.Select(x => x.GetViewModel)
.ToList();
}
else if (model.ClientId.HasValue)
{
return context.Orders
.Include(x => x.Ship)
.Include(x => x.Client)
.Include(x => x.Implementer)
.Include(x => x.Client).Include(x => x.Implementer)
.Where(x => x.ClientId == model.ClientId)
.Select(x => x.GetViewModel)
.ToList();
}
else if (model.ImplementerId.HasValue)
{
else if (model.Status.HasValue)
return context.Orders
.Include(x => x.Ship)
.Include(x => x.Client).Include(x => x.Implementer)
.Where(x => x.Status == model.Status)
.Select(x => x.GetViewModel)
.ToList();
else if (model.Id.HasValue)
return context.Orders
.Include(x => x.Ship)
.Include(x => x.Client)
.Include(x => x.Implementer)
.Where(x => x.ImplementerId == model.ImplementerId)
.Include(x => x.Client).Include(x => x.Implementer)
.Where(x => x.Id == model.Id)
.Select(x => x.GetViewModel)
.ToList();
}
return context.Orders
.Include(x => x.Ship)
.Include(x => x.Client)
.Include(x => x.Implementer)
.Where(x => model.Status == x.Status)
.Select(x => x.GetViewModel)
.ToList();
return new();
}
public List<OrderViewModel> GetFullList()