diff --git a/MotorPlant/MotorPlantBusinessLogic/ReportLogic.cs b/MotorPlant/MotorPlantBusinessLogic/ReportLogic.cs index 0b33161..62e4e4c 100644 --- a/MotorPlant/MotorPlantBusinessLogic/ReportLogic.cs +++ b/MotorPlant/MotorPlantBusinessLogic/ReportLogic.cs @@ -15,7 +15,6 @@ namespace MotorPlantBusinessLogic { public class ReportLogic : IReportLogic { - private readonly IComponentStorage _componentStorage; private readonly IEngineStorage _EngineStorage; private readonly IOrderStorage _orderStorage; private readonly AbstractSaveToExcel _saveToExcel; @@ -24,7 +23,6 @@ namespace MotorPlantBusinessLogic public ReportLogic(IEngineStorage EngineStorage, IComponentStorage componentStorage, IOrderStorage orderStorage, AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf) { _EngineStorage = EngineStorage; - _componentStorage = componentStorage; _orderStorage = orderStorage; _saveToExcel = saveToExcel; _saveToWord = saveToWord; @@ -32,13 +30,25 @@ namespace MotorPlantBusinessLogic } public List GetEngineComponents() { - return _EngineStorage.GetFullList().Select(x => new ReportEngineComponentViewModel - { - EngineName = x.EngineName, - Components = x.EngineComponents.Select(x => (x.Value.Item1.ComponentName, x.Value.Item2)).ToList(), - TotalCount = x.EngineComponents.Select(x => x.Value.Item2).Sum() - }).ToList(); - } + var Engines = _EngineStorage.GetFullList(); + var list = new List(); + foreach (var Engine in Engines) + { + var record = new ReportEngineComponentViewModel + { + EngineName = Engine.EngineName, + Components = new List<(string Component, int Count)>(), + TotalCount = 0 + }; + foreach (var component in Engine.EngineComponents) + { + record.Components.Add(new(component.Value.Item1.ComponentName, component.Value.Item2)); + record.TotalCount += component.Value.Item2; + } + list.Add(record); + } + return list; + } public List GetOrders(ReportBindingModel model) { return _orderStorage.GetFilteredList(new OrderSearchModel