From 5770b41ad7e5cda7610677379a13983f0d188760 Mon Sep 17 00:00:00 2001 From: Suphonchai Phoonsawat Date: Wed, 3 Jul 2024 11:08:02 +0700 Subject: [PATCH] =?UTF-8?q?fix=20=E0=B8=84=E0=B8=B3=E0=B8=99=E0=B8=A7?= =?UTF-8?q?=E0=B8=99=E0=B9=80=E0=B8=84=E0=B8=A3=E0=B8=B7=E0=B9=88=E0=B8=AD?= =?UTF-8?q?=E0=B8=87=E0=B8=A3=E0=B8=B2=E0=B8=8A=E0=B8=A2=E0=B9=8C=E0=B8=A5?= =?UTF-8?q?=E0=B8=B9=E0=B8=81=E0=B8=88=E0=B9=89=E0=B8=B2=E0=B8=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Repositories/InsigniaPeriodsRepository.cs | 52 ++++++++++++++----- 1 file changed, 38 insertions(+), 14 deletions(-) diff --git a/BMA.EHR.Application/Repositories/InsigniaPeriodsRepository.cs b/BMA.EHR.Application/Repositories/InsigniaPeriodsRepository.cs index a78c2923..11ff2103 100644 --- a/BMA.EHR.Application/Repositories/InsigniaPeriodsRepository.cs +++ b/BMA.EHR.Application/Repositories/InsigniaPeriodsRepository.cs @@ -361,7 +361,13 @@ namespace BMA.EHR.Application.Repositories var jtmRoyal = await _dbContext.Set().FirstOrDefaultAsync(x => x.Name.Contains("จัตุรถาภรณ์มงกุฎไทย")); var s2 = (from p in allProfilesByRoot - where !(p.ProfileInsignia.Where(x => x.InsigniaId != coinInsignia.Id).OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId == bcpRoyal.Id) + where p.ProfileInsignia != null + && p.ProfileInsignia.Count > 0 + && (p.ProfileInsignia.Where(x => x.InsigniaId.Value != coinInsignia.Id && + x.InsigniaId.Value == bcpRoyal.Id) + .ToList() + .Count() == 0) + //where !(p.ProfileInsignia.Where(x => x.InsigniaId != coinInsignia.Id).OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId == bcpRoyal.Id) select new { ProfileId = p.Id, @@ -433,7 +439,13 @@ namespace BMA.EHR.Application.Repositories var s3 = (from p in allProfilesByRoot - where !(p.ProfileInsignia.Where(x => x.InsigniaId != coinInsignia.Id).OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId == jtmRoyal.Id) + where p.ProfileInsignia != null + && p.ProfileInsignia.Count > 0 + && (p.ProfileInsignia.Where(x => x.InsigniaId.Value != coinInsignia.Id && + x.InsigniaId.Value == jtmRoyal.Id) + .ToList() + .Count() == 0) + //where !(p.ProfileInsignia.Where(x => x.InsigniaId != coinInsignia.Id).OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId == jtmRoyal.Id) select new { ProfileId = p.Id, @@ -551,8 +563,8 @@ namespace BMA.EHR.Application.Repositories continue; // Check ว่าชั้นที่ขอสูงกว่าชั้นที่เคยได้รับแล้วหรือไม่? - if (!IsHigherLevel2(r.LastInsignia, r.RequestInsignia.Name)) - continue; + //if (!IsHigherLevel2(r.LastInsignia, r.RequestInsignia.Name)) + // continue; if (old == null) { @@ -666,7 +678,13 @@ namespace BMA.EHR.Application.Repositories var jtmRoyal = await _dbContext.Set().FirstOrDefaultAsync(x => x.Name.Contains("จัตุรถาภรณ์มงกุฎไทย")); var s2 = (from p in allProfilesByRoot - where !(p.ProfileInsignia.Where(x => x.InsigniaId != coinInsignia.Id).OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId == jtmRoyal.Id) + where p.ProfileInsignia != null + && p.ProfileInsignia.Count > 0 + && (p.ProfileInsignia.Where(x => x.InsigniaId.Value != coinInsignia.Id && + x.InsigniaId.Value == jtmRoyal.Id) + .ToList() + .Count() == 0) + //where !(p.ProfileInsignia.Where(x => x.InsigniaId != coinInsignia.Id).OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId == jtmRoyal.Id) select new { ProfileId = p.Id, @@ -738,7 +756,13 @@ namespace BMA.EHR.Application.Repositories .ToList(); var s3 = (from p in allProfilesByRoot - where !(p.ProfileInsignia.Where(x => x.InsigniaId != coinInsignia.Id).OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId == jtcRoyal.Id) + where p.ProfileInsignia != null + && p.ProfileInsignia.Count > 0 + && (p.ProfileInsignia.Where(x => x.InsigniaId.Value != coinInsignia.Id && + x.InsigniaId.Value == jtcRoyal.Id) + .ToList() + .Count() == 0) + //where !(p.ProfileInsignia.Where(x => x.InsigniaId != coinInsignia.Id).OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId == jtcRoyal.Id) select new { ProfileId = p.Id, @@ -856,8 +880,8 @@ namespace BMA.EHR.Application.Repositories continue; // Check ว่าชั้นที่ขอสูงกว่าชั้นที่เคยได้รับแล้วหรือไม่? - if (!IsHigherLevel2(r.LastInsignia, r.RequestInsignia.Name)) - continue; + //if (!IsHigherLevel2(r.LastInsignia, r.RequestInsignia.Name)) + // continue; if (old == null) { @@ -942,12 +966,12 @@ namespace BMA.EHR.Application.Repositories where p.ProfileDateAppoint <= new DateTime(period.Year - 5, 5, 29) && p.LastInsigniaId == Guid.Parse("00000000-0000-0000-0000-000000000000") && p.PositionLevelName == "ปฏิบัติงาน" // ปฏิบัติงาน - && p.ProfileInsignia != null - && p.ProfileInsignia.Count > 0 - && (p.ProfileInsignia.Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id && - x.InsigniaId.Value == GetInsigniaByName("เบญจมาภรณ์มงกุฎไทย").Id) - .ToList() - .Count() == 0) + && p.ProfileInsignia == null + //&& p.ProfileInsignia.Count > 0 + //&& p.ProfileInsignia.Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id && + // x.InsigniaId.Value == GetInsigniaByName("เบญจมาภรณ์มงกุฎไทย").Id) + // .ToList() + // .Count() == 0) select p) .ToList() .Select(p => new InsigniaResultSet