From 63f5efce0af3f502001148ad03028b2f8d2f64b9 Mon Sep 17 00:00:00 2001 From: Salikh Date: Sat, 6 Apr 2024 23:43:11 +0400 Subject: [PATCH] final commit --- .../BusinessLogic/ReportLogic.cs | 7 +++++-- .../Implements/OrderStorage.cs | 11 +++++++---- .../Implements/OrderStorage.cs | 10 +++++++--- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/MotorPlant/MotorPlantBusinessLogic/BusinessLogic/ReportLogic.cs b/MotorPlant/MotorPlantBusinessLogic/BusinessLogic/ReportLogic.cs index 7f284bb..9483f6d 100644 --- a/MotorPlant/MotorPlantBusinessLogic/BusinessLogic/ReportLogic.cs +++ b/MotorPlant/MotorPlantBusinessLogic/BusinessLogic/ReportLogic.cs @@ -15,7 +15,9 @@ namespace MotorPlantBusinessLogic.BusinessLogic { public class ReportLogic : IReportLogic { - private readonly IEngineStorage _engineStorage; + private readonly IComponentStorage _componentStorage; + + private readonly IEngineStorage _engineStorage; private readonly IOrderStorage _orderStorage; @@ -29,7 +31,8 @@ namespace MotorPlantBusinessLogic.BusinessLogic AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf) { _engineStorage = engineStorage; - _orderStorage = orderStorage; + _componentStorage = componentStorage; + _orderStorage = orderStorage; _saveToExcel = saveToExcel; _saveToWord = saveToWord; diff --git a/MotorPlant/MotorPlantFileImplement/Implements/OrderStorage.cs b/MotorPlant/MotorPlantFileImplement/Implements/OrderStorage.cs index d79a83b..80f0646 100644 --- a/MotorPlant/MotorPlantFileImplement/Implements/OrderStorage.cs +++ b/MotorPlant/MotorPlantFileImplement/Implements/OrderStorage.cs @@ -31,12 +31,15 @@ namespace MotorPlantFileImplement.Implements public List GetFilteredList(OrderSearchModel model) { - if (!model.Id.HasValue) - { + if (!model.Id.HasValue && !model.DateFrom.HasValue || !model.DateTo.HasValue) + { return new(); } - return source.Orders.Where(x => x.Id == model.Id).Select(x => GetViewModel(x)).ToList(); - } + return source.Orders + .Where(x => x.Id == model.Id || (model.DateTo >= x.DateCreate && model.DateFrom <= x.DateCreate)) + .Select(x => GetViewModel(x)) + .ToList(); + } public List GetFullList() { diff --git a/MotorPlant/MotorPlantListImplement/Implements/OrderStorage.cs b/MotorPlant/MotorPlantListImplement/Implements/OrderStorage.cs index 5e75a80..a973288 100644 --- a/MotorPlant/MotorPlantListImplement/Implements/OrderStorage.cs +++ b/MotorPlant/MotorPlantListImplement/Implements/OrderStorage.cs @@ -35,10 +35,14 @@ namespace MotorPlantListImplement.Implements { return result; } - foreach (var order in _source.Orders) + if (!model.DateFrom.HasValue || !model.DateTo.HasValue) + { + return result; + } + foreach (var order in _source.Orders) { - if (order.Id == model.Id) - { + if (order.Id == model.Id || (model.DateFrom <= order.DateCreate && order.DateCreate <= model.DateTo)) + { result.Add(AttachEngineName(order.GetViewModel)); } }