diff --git a/ServiceStation/ServiceStationBusinessLogic/BusinessLogics/ExecutorReportLogic.cs b/ServiceStation/ServiceStationBusinessLogic/BusinessLogics/ExecutorReportLogic.cs index 27013af..f77a4e8 100644 --- a/ServiceStation/ServiceStationBusinessLogic/BusinessLogics/ExecutorReportLogic.cs +++ b/ServiceStation/ServiceStationBusinessLogic/BusinessLogics/ExecutorReportLogic.cs @@ -100,9 +100,9 @@ namespace ServiceStationBusinessLogic.BusinessLogics }); List defectList = _defectStorage.GetFullList(); + List<(DefectViewModel, int)> defects = new(); - - foreach(var techWork in techWorkList) + foreach (var techWork in techWorkList) { foreach(var car in techWork.TechnicalWorkCars.Values) { @@ -114,30 +114,45 @@ namespace ServiceStationBusinessLogic.BusinessLogics TechnicalWorkDate = techWork.DateStartWork, TechnicalWorkPrice = techWork.WorkPrice, }); - List defects = new(); + foreach (var defect in defectList) { if (defect.DefectCars.ContainsKey(car.Id)) { - defects.Add(defect); + int contains = 0; + foreach (var defectt in defects) + { + if (defectt.Item2 == car.Id && defect.DefectType == defectt.Item1.DefectType) + { + contains++; + } + } + if(contains == 0) + { + defects.Add(new(defect, car.Id)); + } } } - - foreach(var defect in defects) - { - //if (defect.RepairId.HasValue) - //{ - var repair = _repairStorage.GetElement(new RepairSearchModel { Id = 1 }); - allList.Add(new ReportCarsViewModel - { - RepairName = repair.RepairName, - RepairStartDate = repair.RepairStartDate, - RepairPrice = repair.RepairPrice, - }); - //} - } } } + + + foreach (var defect in defects) + { + //if (defect.RepairId.HasValue) + //{ + var repair = _repairStorage.GetElement(new RepairSearchModel { Id = 1 }); + var car = _carStorage.GetElement(new CarSearchModel { Id = defect.Item2 }); + allList.Add(new ReportCarsViewModel + { + CarNumber = car.CarNumber, + CarBrand = car.CarBrand, + RepairName = repair.RepairName, + RepairStartDate = repair.RepairStartDate, + RepairPrice = repair.RepairPrice, + }); + //} + } return allList; }