From f129c4d785973732bcf2ba556f15c0f9774fa237 Mon Sep 17 00:00:00 2001 From: Marselchi Date: Tue, 30 Apr 2024 22:42:35 +0400 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=BD=D1=8B=20=D0=BF=D0=BE=D0=BB=D1=8F=20=D0=B4=D0=BB?= =?UTF-8?q?=D1=8F=20=D0=BF=D0=BE=D0=B8=D1=81=D0=BA=D0=B0=20=D0=BF=D0=BE=20?= =?UTF-8?q?=D0=BF=D0=B5=D1=80=D0=B8=D0=BE=D0=B4=D1=83=20=D0=B2=20=D0=BC?= =?UTF-8?q?=D0=BE=D0=B4=D0=B5=D0=BB=D1=8C=20=D0=BF=D0=BE=D0=BA=D1=83=D0=BF?= =?UTF-8?q?=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SearchModels/OrderSearchModel.cs | 8 +++-- .../Implements/OrderStorage.cs | 30 ++++++++++++++++++- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/CarCenter/CarCenterContracts/SearchModels/OrderSearchModel.cs b/CarCenter/CarCenterContracts/SearchModels/OrderSearchModel.cs index 9087f3a..51c09cc 100644 --- a/CarCenter/CarCenterContracts/SearchModels/OrderSearchModel.cs +++ b/CarCenter/CarCenterContracts/SearchModels/OrderSearchModel.cs @@ -1,4 +1,5 @@ -using System; +using CarCenterDataModels.Models; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -9,5 +10,8 @@ namespace CarCenterContracts.SearchModels public class OrderSearchModel { public int? Id { get; set; } - } + public List Presales { get; set; } = new(); + public DateTime? DateFrom { get; set; } + public DateTime? DateTo { get; set; } + } } diff --git a/CarCenter/CarCenterDatabaseImplement/Implements/OrderStorage.cs b/CarCenter/CarCenterDatabaseImplement/Implements/OrderStorage.cs index 1b154a0..0fe2fd8 100644 --- a/CarCenter/CarCenterDatabaseImplement/Implements/OrderStorage.cs +++ b/CarCenter/CarCenterDatabaseImplement/Implements/OrderStorage.cs @@ -54,7 +54,35 @@ namespace CarCenterDatabaseImplement.Implements public List GetFilteredList(OrderSearchModel model) { using var context = new CarCenterDatabase(); - if (model.Id.HasValue) + + if (model.DateFrom.HasValue && model.DateTo.HasValue) //для отчета + { + return context.Orders + .Include(x => x.Worker) + .Include(x => x.Cars) + .Include(x => x.Presales) + .ThenInclude(x => x.Presale) + .ThenInclude(x => x.Requests) + .Include(x => x.Presales) + .ThenInclude(x => x.Presale) + .ThenInclude(x => x.Bundlings) + .ThenInclude(x => x.Bundling) + .Where(x => x.PaymentDate >= model.DateFrom && x.PaymentDate <= model.DateTo) + .Select(x => x.GetViewModel) + .ToList(); + } + else if (model.Presales.Count > 0) //для отчета + { + return context.Orders + .Include(x => x.Worker) + .Include(x => x.Cars) + .Include(x => x.Presales) + .ThenInclude(x => x.Presale) + .Where(x => x.OrderPresales.Any(p => model.Presales.Any(presale => p.Value == presale))) + .Select(x => x.GetViewModel) + .ToList(); + } + else if (model.Id.HasValue) { return context.Orders .Include(x => x.Worker)