шаманю

This commit is contained in:
kamilia 2024-05-19 13:35:53 +04:00
parent ab6b3d0d15
commit c646b88323
2 changed files with 8 additions and 44 deletions

View File

@ -190,6 +190,10 @@ namespace AircraftPlantBusinessLogic.BusinessLogics
model.Status = newStatus; model.Status = newStatus;
if (element.ImplementerId.HasValue)
{
model.ImplementerId = element.ImplementerId;
}
if (model.Status == OrderStatus.Готов) if (model.Status == OrderStatus.Готов)
{ {
model.DateImplement = DateTime.Now; model.DateImplement = DateTime.Now;

View File

@ -15,14 +15,13 @@ namespace AircraftPlantDatabaseImplement.Implements
return context.Orders return context.Orders
.Include(x => x.Plane) .Include(x => x.Plane)
.Include(x => x.Client) .Include(x => x.Client)
.Include(x => x.Implementer)
.Select(x => x.GetViewModel) .Select(x => x.GetViewModel)
.ToList(); .ToList();
} }
public List<OrderViewModel> GetFilteredList(OrderSearchModel model) public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
{ {
if (!model.Id.HasValue && !model.ClientId.HasValue && (!model.DateFrom.HasValue || !model.DateTo.HasValue) && model.Status == null) if (!model.Id.HasValue && !model.ClientId.HasValue && (!model.DateFrom.HasValue || !model.DateTo.HasValue))
{ {
return new(); return new();
} }
@ -32,29 +31,16 @@ namespace AircraftPlantDatabaseImplement.Implements
return context.Orders return context.Orders
.Include(x => x.Client) .Include(x => x.Client)
.Include(x => x.Plane) .Include(x => x.Plane)
.Include(x => x.Implementer)
.Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo) .Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo)
.Select(x => x.GetViewModel) .Select(x => x.GetViewModel)
.ToList(); .ToList();
} }
if (model.Status.HasValue)
{
return context.Orders
.Include(x => x.Plane)
.Include(x => x.Client)
.Include(x => x.Implementer)
.Where(x => x.Status == model.Status)
.Select(x => x.GetViewModel)
.ToList();
}
if (model.ClientId.HasValue) if (model.ClientId.HasValue)
{ {
return context.Orders return context.Orders
.Include(x => x.Plane) .Include(x => x.Plane)
.Include(x => x.Client) .Include(x => x.Client)
.Include(x => x.Implementer)
.Where(x => x.ClientId == model.ClientId) .Where(x => x.ClientId == model.ClientId)
.Select(x => x.GetViewModel) .Select(x => x.GetViewModel)
.ToList(); .ToList();
@ -75,37 +61,11 @@ namespace AircraftPlantDatabaseImplement.Implements
return null; return null;
} }
using var context = new AircraftPlantDatabase(); using var context = new AircraftPlantDatabase();
if (model.Id.HasValue)
{
return context.Orders return context.Orders
.Include(x => x.Plane) .Include(x => x.Plane)
.Include(x => x.Client) .Include(x => x.Client)
.Include(x => x.Implementer) .FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?
.FirstOrDefault(x => x.Id == model.Id) .GetViewModel;
?.GetViewModel;
}
if (model.ImplementerId.HasValue && model.Status.HasValue)
{
return context.Orders
.Include(x => x.Plane)
.Include(x => x.Client)
.Include(x => x.Implementer)
.FirstOrDefault(x => x.ImplementerId == model.ImplementerId && x.Status == model.Status)
?.GetViewModel;
}
if (model.ImplementerId.HasValue)
{
return context.Orders
.Include(x => x.Plane)
.Include(x => x.Client)
.Include(x => x.Implementer)
.FirstOrDefault(x => x.ImplementerId == model.ImplementerId)
?.GetViewModel;
}
return null;
} }
public OrderViewModel? Insert(OrderBindingModel model) public OrderViewModel? Insert(OrderBindingModel model)