From 79fe8e39c34bc020d1411f3d588afc84fdbb3a7d Mon Sep 17 00:00:00 2001 From: Marselchi Date: Tue, 30 Apr 2024 23:05:36 +0400 Subject: [PATCH] =?UTF-8?q?=D0=92=D1=80=D0=BE=D0=B4=D0=B5=20=D1=83=D1=81?= =?UTF-8?q?=D1=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SearchModels/CarSearchModel.cs | 4 +++- .../SearchModels/OrderSearchModel.cs | 1 + .../Implements/CarStorage.cs | 14 +++++++++++++- .../Implements/OrderStorage.cs | 15 +++++++++++++-- 4 files changed, 30 insertions(+), 4 deletions(-) diff --git a/CarCenter/CarCenterContracts/SearchModels/CarSearchModel.cs b/CarCenter/CarCenterContracts/SearchModels/CarSearchModel.cs index f304e36..58299fa 100644 --- a/CarCenter/CarCenterContracts/SearchModels/CarSearchModel.cs +++ b/CarCenter/CarCenterContracts/SearchModels/CarSearchModel.cs @@ -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; } + } } diff --git a/CarCenter/CarCenterContracts/SearchModels/OrderSearchModel.cs b/CarCenter/CarCenterContracts/SearchModels/OrderSearchModel.cs index 51c09cc..95be01d 100644 --- a/CarCenter/CarCenterContracts/SearchModels/OrderSearchModel.cs +++ b/CarCenter/CarCenterContracts/SearchModels/OrderSearchModel.cs @@ -11,6 +11,7 @@ namespace CarCenterContracts.SearchModels { public int? Id { get; set; } public List Presales { get; set; } = new(); + public List Cars { get; set; } = new(); public DateTime? DateFrom { get; set; } public DateTime? DateTo { get; set; } } diff --git a/CarCenter/CarCenterDatabaseImplement/Implements/CarStorage.cs b/CarCenter/CarCenterDatabaseImplement/Implements/CarStorage.cs index 906e52b..d62831f 100644 --- a/CarCenter/CarCenterDatabaseImplement/Implements/CarStorage.cs +++ b/CarCenter/CarCenterDatabaseImplement/Implements/CarStorage.cs @@ -29,7 +29,19 @@ namespace CarCenterDatabaseImplement.Implements public List 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) diff --git a/CarCenter/CarCenterDatabaseImplement/Implements/OrderStorage.cs b/CarCenter/CarCenterDatabaseImplement/Implements/OrderStorage.cs index 0fe2fd8..ca1579a 100644 --- a/CarCenter/CarCenterDatabaseImplement/Implements/OrderStorage.cs +++ b/CarCenter/CarCenterDatabaseImplement/Implements/OrderStorage.cs @@ -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