Доделал1

This commit is contained in:
[USERNAME] 2024-04-21 13:28:27 +04:00
parent 95899c05ee
commit 8b341f85a1

View File

@ -15,7 +15,6 @@ namespace MotorPlantBusinessLogic
{ {
public class ReportLogic : IReportLogic public class ReportLogic : IReportLogic
{ {
private readonly IComponentStorage _componentStorage;
private readonly IEngineStorage _EngineStorage; private readonly IEngineStorage _EngineStorage;
private readonly IOrderStorage _orderStorage; private readonly IOrderStorage _orderStorage;
private readonly AbstractSaveToExcel _saveToExcel; private readonly AbstractSaveToExcel _saveToExcel;
@ -24,7 +23,6 @@ namespace MotorPlantBusinessLogic
public ReportLogic(IEngineStorage EngineStorage, IComponentStorage componentStorage, IOrderStorage orderStorage, AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf) public ReportLogic(IEngineStorage EngineStorage, IComponentStorage componentStorage, IOrderStorage orderStorage, AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf)
{ {
_EngineStorage = EngineStorage; _EngineStorage = EngineStorage;
_componentStorage = componentStorage;
_orderStorage = orderStorage; _orderStorage = orderStorage;
_saveToExcel = saveToExcel; _saveToExcel = saveToExcel;
_saveToWord = saveToWord; _saveToWord = saveToWord;
@ -32,12 +30,24 @@ namespace MotorPlantBusinessLogic
} }
public List<ReportEngineComponentViewModel> GetEngineComponents() public List<ReportEngineComponentViewModel> GetEngineComponents()
{ {
return _EngineStorage.GetFullList().Select(x => new ReportEngineComponentViewModel var Engines = _EngineStorage.GetFullList();
var list = new List<ReportEngineComponentViewModel>();
foreach (var Engine in Engines)
{ {
EngineName = x.EngineName, var record = new ReportEngineComponentViewModel
Components = x.EngineComponents.Select(x => (x.Value.Item1.ComponentName, x.Value.Item2)).ToList(), {
TotalCount = x.EngineComponents.Select(x => x.Value.Item2).Sum() EngineName = Engine.EngineName,
}).ToList(); 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<ReportOrdersViewModel> GetOrders(ReportBindingModel model) public List<ReportOrdersViewModel> GetOrders(ReportBindingModel model)
{ {