diff --git a/AircraftPlant/AircraftPlantBusinessLogic/BusinessLogics/OrderLogic.cs b/AircraftPlant/AircraftPlantBusinessLogic/BusinessLogics/OrderLogic.cs index 704e5fd..27e9bbd 100644 --- a/AircraftPlant/AircraftPlantBusinessLogic/BusinessLogics/OrderLogic.cs +++ b/AircraftPlant/AircraftPlantBusinessLogic/BusinessLogics/OrderLogic.cs @@ -190,6 +190,10 @@ namespace AircraftPlantBusinessLogic.BusinessLogics model.Status = newStatus; + if (element.ImplementerId.HasValue) + { + model.ImplementerId = element.ImplementerId; + } if (model.Status == OrderStatus.Готов) { model.DateImplement = DateTime.Now; diff --git a/AircraftPlant/AircraftPlantDatabaseImplement/Implements/OrderStorage.cs b/AircraftPlant/AircraftPlantDatabaseImplement/Implements/OrderStorage.cs index 1a86b27..745c49e 100644 --- a/AircraftPlant/AircraftPlantDatabaseImplement/Implements/OrderStorage.cs +++ b/AircraftPlant/AircraftPlantDatabaseImplement/Implements/OrderStorage.cs @@ -15,14 +15,13 @@ namespace AircraftPlantDatabaseImplement.Implements return context.Orders .Include(x => x.Plane) .Include(x => x.Client) - .Include(x => x.Implementer) .Select(x => x.GetViewModel) .ToList(); } public List 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(); } @@ -32,29 +31,16 @@ namespace AircraftPlantDatabaseImplement.Implements return context.Orders .Include(x => x.Client) .Include(x => x.Plane) - .Include(x => x.Implementer) .Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo) .Select(x => x.GetViewModel) .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) { return context.Orders .Include(x => x.Plane) .Include(x => x.Client) - .Include(x => x.Implementer) .Where(x => x.ClientId == model.ClientId) .Select(x => x.GetViewModel) .ToList(); @@ -75,37 +61,11 @@ namespace AircraftPlantDatabaseImplement.Implements return null; } using var context = new AircraftPlantDatabase(); - if (model.Id.HasValue) - { - return context.Orders + return context.Orders .Include(x => x.Plane) .Include(x => x.Client) - .Include(x => x.Implementer) - .FirstOrDefault(x => x.Id == model.Id) - ?.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; + .FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))? + .GetViewModel; } public OrderViewModel? Insert(OrderBindingModel model)