From df55a3ea4081b58bbfba0ca437b7bbc26bcb87a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D0=BA=D1=81=D0=B8=D0=BC=20=D0=AF=D0=BA=D0=BE?= =?UTF-8?q?=D0=B2=D0=BB=D0=B5=D0=B2?= Date: Tue, 28 May 2024 17:49:22 +0400 Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=BE=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D0=B0=D0=BB=20=D0=BE=D1=82=D1=87=D0=B5=D1=82=D1=8B=20=D0=B4?= =?UTF-8?q?=D0=BE=20=D0=BA=D0=BE=D0=BD=D1=86=D0=B0,=20=D0=BE=D1=81=D1=82?= =?UTF-8?q?=D0=B0=D0=BB=D0=B0=D1=81=D1=8C=20=D0=BF=D0=BE=D1=87=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BusinessLogics/ExecutorReportLogic.cs | 51 ++++++++++++------- 1 file changed, 33 insertions(+), 18 deletions(-) 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; }