Исправление в отчете по изделиям и компонентам

This commit is contained in:
prodigygirl 2023-03-24 16:16:30 +04:00
parent 557c072e39
commit e3dbc8c49a

View File

@ -15,17 +15,15 @@ namespace FurnitureAssemblyBusinessLogic
{
public class ReportLogic : IReportLogic
{
private readonly IComponentStorage _componentStorage;
private readonly IFurnitureStorage _furnitureStorage;
private readonly IOrderStorage _orderStorage;
private readonly AbstractSaveToExcel _saveToExcel;
private readonly AbstractSaveToWord _saveToWord;
private readonly AbstractSaveToPdf _saveToPdf;
public ReportLogic(IFurnitureStorage furnitureStorage, IComponentStorage componentStorage, IOrderStorage orderStorage,
public ReportLogic(IFurnitureStorage furnitureStorage, IOrderStorage orderStorage,
AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf)
{
_furnitureStorage = furnitureStorage;
_componentStorage = componentStorage;
_orderStorage = orderStorage;
_saveToExcel = saveToExcel;
_saveToWord = saveToWord;
@ -38,7 +36,6 @@ namespace FurnitureAssemblyBusinessLogic
public List<ReportFurnitureComponentViewModel> GetFurnitureComponent()
{
var furnitures = _furnitureStorage.GetFullList();
var components = _componentStorage.GetFullList();
var list = new List<ReportFurnitureComponentViewModel>();
foreach (var furniture in furnitures)
{
@ -48,13 +45,10 @@ namespace FurnitureAssemblyBusinessLogic
Components = new List<Tuple<string, int>>(),
TotalCount = 0
};
foreach (var component in components)
foreach (var componentCount in furniture.FurnitureComponents.Values)
{
if (furniture.FurnitureComponents.ContainsKey(component.Id))
{
record.Components.Add(new Tuple<string, int>(component.ComponentName, furniture.FurnitureComponents[component.Id].Item2));
record.TotalCount += furniture.FurnitureComponents[component.Id].Item2;
}
record.Components.Add(new Tuple<string, int>(componentCount.Item1.ComponentName, componentCount.Item2));
record.TotalCount += componentCount.Item2;
}
list.Add(record);
}