LabWork04_Base: Фиксы

This commit is contained in:
Safgerd 2023-04-09 21:34:28 +04:00
parent f77d3f66cc
commit fc5a9b69c5

View File

@ -33,7 +33,6 @@ namespace AutomobilePlantBusinessLogic.BusinessLogics
/// Получение списка компонент с указанием, в каких изделиях используются /// Получение списка компонент с указанием, в каких изделиях используются
public List<ReportCarComponentViewModel> GetCarComponents() public List<ReportCarComponentViewModel> GetCarComponents()
{ {
var components = _componentStorage.GetFullList();
var cars = _carStorage.GetFullList(); var cars = _carStorage.GetFullList();
var list = new List<ReportCarComponentViewModel>(); var list = new List<ReportCarComponentViewModel>();
foreach (var car in cars) foreach (var car in cars)
@ -44,13 +43,10 @@ namespace AutomobilePlantBusinessLogic.BusinessLogics
Components = new List<(string Component, int Count)>(), Components = new List<(string Component, int Count)>(),
TotalCount = 0 TotalCount = 0
}; };
foreach (var component in components) foreach (var component in car.CarComponents.Values)
{ {
if (car.CarComponents.ContainsKey(component.Id)) record.Components.Add((component.Item1.ComponentName, component.Item2));
{ record.TotalCount += component.Item2;
record.Components.Add(new(component.ComponentName, car.CarComponents[component.Id].Item2));
record.TotalCount += car.CarComponents[component.Id].Item2;
}
} }
list.Add(record); list.Add(record);
} }