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

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

View File

@ -14,18 +14,16 @@ using System.Threading.Tasks;
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;
@ -37,8 +35,7 @@ namespace FurnitureAssemblyBusinessLogic
/// <returns></returns>
public List<ReportFurnitureComponentViewModel> GetFurnitureComponent()
{
var furnitures = _furnitureStorage.GetFullList();
var components = _componentStorage.GetFullList();
var furnitures = _furnitureStorage.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)
{
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;
}
foreach (var componentCount in furniture.FurnitureComponents.Values)
{
record.Components.Add(new Tuple<string, int>(componentCount.Item1.ComponentName, componentCount.Item2));
record.TotalCount += componentCount.Item2;
}
list.Add(record);
}