From 826aa8db19202bc3d38595842edbfc2d1c72a094 Mon Sep 17 00:00:00 2001 From: Suphonchai Phoonsawat Date: Thu, 19 Jun 2025 13:06:22 +0700 Subject: [PATCH] fix employee insignia request cal --- .../Repositories/InsigniaPeriodsRepository.cs | 242 +++++++++--------- 1 file changed, 128 insertions(+), 114 deletions(-) diff --git a/BMA.EHR.Application/Repositories/InsigniaPeriodsRepository.cs b/BMA.EHR.Application/Repositories/InsigniaPeriodsRepository.cs index 7655e052..a520f502 100644 --- a/BMA.EHR.Application/Repositories/InsigniaPeriodsRepository.cs +++ b/BMA.EHR.Application/Repositories/InsigniaPeriodsRepository.cs @@ -151,6 +151,17 @@ namespace BMA.EHR.Application.Repositories } } + private static bool IsHigherLevel(BMA.EHR.Application.Responses.Profiles.ProfileInsignia? last, string request) + { + if (last == null) + return true; + else + { + var last_ins = last.Insignia?.ToLower().Trim() ?? ""; + return IsHigherLevel(last_ins, request); + } + } + private static bool IsHigherLevel(string last, string request) { if (request.Contains("ตริตาภรณ์ช้างเผือก")) @@ -395,82 +406,85 @@ namespace BMA.EHR.Application.Repositories var jtmRoyal = await _dbContext.Set() .FirstOrDefaultAsync(x => x.Name.Contains("จัตุรถาภรณ์มงกุฎไทย")); - var s2 = (from p in allProfilesByRoot - 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) - select new - { - ProfileId = p.Id, - p.CitizenId, - p.FirstName, - p.LastName, - p.BirthDate, - p.DateAppoint, - Prefix = p.Prefix ?? "", - FullName = $"{(p.Prefix ?? "")}{p.FirstName} {p.LastName}", - Position = p.Position ?? "", - Rank = p.PosLevel ?? "", - ProfileDateAppoint = p.DateAppoint.Value, - GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0), - PosNo = p.PosNo, - PositionLevelId = p.PosLevelId, - PositionLevelName = p.PosLevel, - PositionTypeId = p.PosTypeId, - PositionTypeName = p.PosType, - Gender = p.Gender ?? "", - PositionSalaryAmount = p.PositionSalaryAmount ?? 0, - Amount = p.Amount ?? 0, - RootId = p.RootId, - RootDnaId = p.RootDnaId, - Root = p.Root, - Child1Id = p.Child1Id, - Child1DnaId = p.Child1DnaId, - Child1 = p.Child1, - Child2Id = p.Child2Id, - Child2DnaId = p.Child2DnaId, - Child2 = p.Child2, - Child3Id = p.Child3Id, - Child3DnaId = p.Child3DnaId, - Child3 = p.Child3, - Child4Id = p.Child4Id, - Child4DnaId = p.Child4DnaId, - Child4 = p.Child4, - LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 - ? null - : p.ProfileInsignia!.OrderByDescending(x => x.Year).FirstOrDefault()! - .Insignia, - LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 - ? Guid.Parse("00000000-0000-0000-0000-000000000000") - : p.ProfileInsignia!.OrderByDescending(x => x.Year).FirstOrDefault()!.InsigniaId.Value, - Salary = p.Amount, - SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 : - p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) - .OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary - .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) - .OrderByDescending(x => x.Order).FirstOrDefault().Amount : - p.Amount, - IsHigherLevel = IsHigherLevel(p.ProfileInsignia.ToList() - .Where(x => x.InsigniaId.Value != coinInsignia.Id) - .OrderByDescending(x => x.Year) - .FirstOrDefault().Insignia, - "เบญจมาภรณ์ช้างเผือก"), - FirstRecvInsigniaYear = p.ProfileInsignia == null ? 0 : - p.ProfileInsignia.Where(x => x.InsigniaId.Value == bcmRoyal.Id).OrderBy(x => x.Year) - .FirstOrDefault() == null ? 0 : - p.ProfileInsignia.Where(x => x.InsigniaId.Value == bcmRoyal.Id).OrderBy(x => x.Year) - .FirstOrDefault().Year, - ProfileType = p.ProfileType, + var s2_a = (from p in allProfilesByRoot + 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) + select new + { + ProfileId = p.Id, + p.CitizenId, + p.FirstName, + p.LastName, + p.BirthDate, + p.DateAppoint, + Prefix = p.Prefix ?? "", + FullName = $"{(p.Prefix ?? "")}{p.FirstName} {p.LastName}", + Position = p.Position ?? "", + Rank = p.PosLevel ?? "", + ProfileDateAppoint = p.DateAppoint.Value, + GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0), + PosNo = p.PosNo, + PositionLevelId = p.PosLevelId, + PositionLevelName = p.PosLevel, + PositionTypeId = p.PosTypeId, + PositionTypeName = p.PosType, + Gender = p.Gender ?? "", + PositionSalaryAmount = p.PositionSalaryAmount ?? 0, + Amount = p.Amount ?? 0, + RootId = p.RootId, + RootDnaId = p.RootDnaId, + Root = p.Root, + Child1Id = p.Child1Id, + Child1DnaId = p.Child1DnaId, + Child1 = p.Child1, + Child2Id = p.Child2Id, + Child2DnaId = p.Child2DnaId, + Child2 = p.Child2, + Child3Id = p.Child3Id, + Child3DnaId = p.Child3DnaId, + Child3 = p.Child3, + Child4Id = p.Child4Id, + Child4DnaId = p.Child4DnaId, + Child4 = p.Child4, + LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 + ? null + : p.ProfileInsignia!.OrderByDescending(x => x.Year).FirstOrDefault()! + .Insignia, + LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 + ? Guid.Parse("00000000-0000-0000-0000-000000000000") + : p.ProfileInsignia!.OrderByDescending(x => x.Year).FirstOrDefault()!.InsigniaId.Value, + Salary = p.Amount, + SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 : + p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) + .OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary + .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) + .OrderByDescending(x => x.Order).FirstOrDefault().Amount : + p.Amount, + IsHigherLevel = + IsHigherLevel(p.ProfileInsignia.ToList() + .Where(x => x.InsigniaId.Value != coinInsignia.Id) + .OrderByDescending(x => x.Year) + .FirstOrDefault(), + "เบญจมาภรณ์ช้างเผือก"), + FirstRecvInsigniaYear = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? 0 : + p.ProfileInsignia.Where(x => x.InsigniaId.Value == bcmRoyal.Id).OrderBy(x => x.Year) + .FirstOrDefault() == null ? 0 : + p.ProfileInsignia.Where(x => x.InsigniaId.Value == bcmRoyal.Id).OrderBy(x => x.Year) + .FirstOrDefault().Year, + ProfileType = p.ProfileType, - MarkDiscipline = p.MarkDiscipline, - MarkInsignia = p.MarkInsignia, - MarkLeave = p.MarkLeave, - MarkRate = p.MarkRate - }) - .ToList() + MarkDiscipline = p.MarkDiscipline, + MarkInsignia = p.MarkInsignia, + MarkLeave = p.MarkLeave, + MarkRate = p.MarkRate + }) + .ToList(); + + var s2 = s2_a .Where(x => (x.SalaryCondition >= 8340 && x.SalaryCondition < 10150) && !x.IsHigherLevel) .Where(x => x.FirstRecvInsigniaYear != 0 && x.FirstRecvInsigniaYear <= period.Year - 5) .Select(p => new InsigniaResultSet @@ -584,7 +598,7 @@ namespace BMA.EHR.Application.Repositories IsHigherLevel = IsHigherLevel(p.ProfileInsignia.ToList() .Where(x => x.InsigniaId.Value != coinInsignia.Id) .OrderByDescending(x => x.Year) - .FirstOrDefault().Insignia, + .FirstOrDefault(), "จัตุรถาภรณ์มงกุฎไทย"), FirstRecvInsigniaYear = p.ProfileInsignia == null ? 0 : p.ProfileInsignia.Where(x => x.InsigniaId.Value == bcmRoyal.Id).OrderBy(x => x.Year) @@ -950,7 +964,7 @@ namespace BMA.EHR.Application.Repositories IsHigherLevel = IsHigherLevel(p.ProfileInsignia.ToList() .Where(x => x.InsigniaId.Value != coinInsignia.Id) .OrderByDescending(x => x.Year) - .FirstOrDefault().Insignia, + .FirstOrDefault(), "จัตุรถาภรณ์มงกุฎไทย"), FirstRecvInsigniaYear = p.ProfileInsignia == null ? 0 : p.ProfileInsignia.Where(x => x.InsigniaId.Value == bcpRoyal.Id).OrderBy(x => x.Year) @@ -1092,7 +1106,7 @@ namespace BMA.EHR.Application.Repositories IsHigherLevel = IsHigherLevel(p.ProfileInsignia.ToList() .Where(x => x.InsigniaId.Value != coinInsignia.Id) .OrderByDescending(x => x.Year) - .FirstOrDefault().Insignia, + .FirstOrDefault(), "จัตุรถาภรณ์ช้างเผือก"), FirstRecvInsigniaYear = p.ProfileInsignia == null ? 0 : p.ProfileInsignia.Where(x => x.InsigniaId.Value == jtmRoyal.Id).OrderBy(x => x.Year) @@ -1460,7 +1474,7 @@ namespace BMA.EHR.Application.Repositories IsHigherLevel = IsHigherLevel(p.ProfileInsignia .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) .OrderByDescending(x => x.Year) - .FirstOrDefault().Insignia, + .FirstOrDefault(), "เบญจมาภรณ์ช้างเผือก"), PositionSalaryAmount = p.PositionSalaryAmount, Amount = p.Amount, @@ -1613,7 +1627,7 @@ namespace BMA.EHR.Application.Repositories .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) .OrderByDescending(x => x.Year) - .FirstOrDefault().Insignia, + .FirstOrDefault(), "จัตุรถาภรณ์มงกุฎไทย"), PositionSalaryAmount = p.PositionSalaryAmount, Amount = p.Amount, @@ -1759,7 +1773,7 @@ namespace BMA.EHR.Application.Repositories .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) .OrderByDescending(x => x.Year) - .FirstOrDefault().Insignia, + .FirstOrDefault(), "จัตุรถาภรณ์ช้างเผือก"), PositionSalaryAmount = p.PositionSalaryAmount, Amount = p.Amount, @@ -2012,7 +2026,7 @@ namespace BMA.EHR.Application.Repositories .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) .OrderByDescending(x => x.Year) - .FirstOrDefault().Insignia, + .FirstOrDefault(), "ตริตาภรณ์มงกุฎไทย"), PositionLevel = p.PosLevel == null ? "" : p.PosLevel, PositionType = p.PosType == null ? "" : p.PosType, @@ -2158,7 +2172,7 @@ namespace BMA.EHR.Application.Repositories .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) .OrderByDescending(x => x.Year) - .FirstOrDefault().Insignia, + .FirstOrDefault(), "ตริตาภรณ์ช้างเผือก"), PositionLevel = p.PosLevel == null ? "" : p.PosLevel, PositionType = p.PosType == null ? "" : p.PosType, @@ -2376,7 +2390,7 @@ namespace BMA.EHR.Application.Repositories .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) .OrderByDescending(x => x.Year) - .FirstOrDefault().Insignia, + .FirstOrDefault(), "ทวีติยาภรณ์มงกุฎไทย"), PositionLevel = p.PosLevel == null ? "" : p.PosLevel, PositionType = p.PosType == null ? "" : p.PosType, @@ -2527,7 +2541,7 @@ namespace BMA.EHR.Application.Repositories .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) .OrderByDescending(x => x.Year) - .FirstOrDefault().Insignia, + .FirstOrDefault(), "ทวีติยาภรณ์ช้างเผือก"), PositionLevel = p.PosLevel == null ? "" : p.PosLevel, PositionType = p.PosType == null ? "" : p.PosType, @@ -2746,7 +2760,7 @@ namespace BMA.EHR.Application.Repositories .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) .OrderByDescending(x => x.Year) - .FirstOrDefault().Insignia, + .FirstOrDefault(), "ทวีติยาภรณ์ช้างเผือก"), PositionLevel = p.PosLevel == null ? "" : p.PosLevel, PositionType = p.PosType == null ? "" : p.PosType, @@ -2898,7 +2912,7 @@ namespace BMA.EHR.Application.Repositories .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) .OrderByDescending(x => x.Year) - .FirstOrDefault().Insignia, + .FirstOrDefault(), "ประถมาภรณ์มงกุฎไทย"), PositionLevel = p.PosLevel == null ? "" : p.PosLevel, PositionType = p.PosType == null ? "" : p.PosType, @@ -3059,7 +3073,7 @@ namespace BMA.EHR.Application.Repositories .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) .OrderByDescending(x => x.Year) - .FirstOrDefault().Insignia, + .FirstOrDefault(), "ประถมาภรณ์ช้างเผือก"), PositionLevel = p.PosLevel == null ? "" : p.PosLevel, PositionType = p.PosType == null ? "" : p.PosType, @@ -3305,7 +3319,7 @@ namespace BMA.EHR.Application.Repositories .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) .OrderByDescending(x => x.Year) - .FirstOrDefault().Insignia, + .FirstOrDefault(), "ตริตาภรณ์มงกุฎไทย"), PositionLevel = p.PosLevel == null ? "" : p.PosLevel, PositionType = p.PosType == null ? "" : p.PosType, @@ -3510,7 +3524,7 @@ namespace BMA.EHR.Application.Repositories .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) .OrderByDescending(x => x.Year) - .FirstOrDefault().Insignia, + .FirstOrDefault(), "ตริตาภรณ์ช้างเผือก"), PositionLevel = p.PosLevel == null ? "" : p.PosLevel, PositionType = p.PosType == null ? "" : p.PosType, @@ -3668,7 +3682,7 @@ namespace BMA.EHR.Application.Repositories .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) .OrderByDescending(x => x.Year) - .FirstOrDefault().Insignia, + .FirstOrDefault(), "ทวีติยาภรณ์มงกุฎไทย"), PositionLevel = p.PosLevel == null ? "" : p.PosLevel, PositionType = p.PosType == null ? "" : p.PosType, @@ -3829,7 +3843,7 @@ namespace BMA.EHR.Application.Repositories .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) .OrderByDescending(x => x.Year) - .FirstOrDefault().Insignia, + .FirstOrDefault(), "ทวีติยาภรณ์ช้างเผือก"), PositionLevel = p.PosLevel == null ? "" : p.PosLevel, PositionType = p.PosType == null ? "" : p.PosType, @@ -4074,7 +4088,7 @@ namespace BMA.EHR.Application.Repositories .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) .OrderByDescending(x => x.Year) - .FirstOrDefault().Insignia, + .FirstOrDefault(), "ทวีติยาภรณ์ช้างเผือก"), PositionLevel = p.PosLevel == null ? "" : p.PosLevel, PositionType = p.PosType == null ? "" : p.PosType, @@ -4215,7 +4229,7 @@ namespace BMA.EHR.Application.Repositories .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) .OrderByDescending(x => x.Year) - .FirstOrDefault().Insignia, + .FirstOrDefault(), "ประถมาภรณ์มงกุฎไทย"), PositionLevel = p.PosLevel == null ? "" : p.PosLevel, @@ -4449,7 +4463,7 @@ namespace BMA.EHR.Application.Repositories .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) .OrderByDescending(x => x.Year) - .FirstOrDefault().Insignia, + .FirstOrDefault(), "ทวีติยาภรณ์ช้างเผือก"), PositionLevel = p.PosLevel == null ? "" : p.PosLevel, PositionType = p.PosType == null ? "" : p.PosType, @@ -4608,7 +4622,7 @@ namespace BMA.EHR.Application.Repositories .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) .OrderByDescending(x => x.Year) - .FirstOrDefault().Insignia, + .FirstOrDefault(), "ประถมาภรณ์มงกุฎไทย"), PositionLevel = p.PosLevel == null ? "" : p.PosLevel, @@ -4769,7 +4783,7 @@ namespace BMA.EHR.Application.Repositories .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) .OrderByDescending(x => x.Year) - .FirstOrDefault().Insignia, + .FirstOrDefault(), "ประถมาภรณ์ช้างเผือก"), PositionLevel = p.PosLevel == null ? "" : p.PosLevel, PositionType = p.PosType == null ? "" : p.PosType, @@ -5013,7 +5027,7 @@ namespace BMA.EHR.Application.Repositories .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) .OrderByDescending(x => x.Year) - .FirstOrDefault().Insignia, + .FirstOrDefault(), "ประถมาภรณ์ช้างเผือก"), PositionLevel = p.PosLevel == null ? "" : p.PosLevel, PositionType = p.PosType == null ? "" : p.PosType, @@ -5180,7 +5194,7 @@ namespace BMA.EHR.Application.Repositories .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) .OrderByDescending(x => x.Year) - .FirstOrDefault().Insignia, + .FirstOrDefault(), "มหาวชิรมงกุฎ"), PositionLevel = p.PosLevel == null ? "" : p.PosLevel, PositionType = p.PosType == null ? "" : p.PosType, @@ -5348,7 +5362,7 @@ namespace BMA.EHR.Application.Repositories .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) .OrderByDescending(x => x.Year) - .FirstOrDefault().Insignia, + .FirstOrDefault(), "มหาปรมาภรณ์ช้างเผือก"), PositionLevel = p.PosLevel == null ? "" : p.PosLevel, @@ -5596,7 +5610,7 @@ namespace BMA.EHR.Application.Repositories .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) .OrderByDescending(x => x.Year) - .FirstOrDefault().Insignia, + .FirstOrDefault(), "ประถมาภรณ์ช้างเผือก"), PositionLevel = p.PosLevel == null ? "" : p.PosLevel, PositionType = p.PosType == null ? "" : p.PosType, @@ -5763,7 +5777,7 @@ namespace BMA.EHR.Application.Repositories .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) .OrderByDescending(x => x.Year) - .FirstOrDefault().Insignia, + .FirstOrDefault(), "มหาวชิรมงกุฎ"), PositionLevel = p.PosLevel == null ? "" : p.PosLevel, PositionType = p.PosType == null ? "" : p.PosType, @@ -5930,7 +5944,7 @@ namespace BMA.EHR.Application.Repositories .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) .OrderByDescending(x => x.Year) - .FirstOrDefault().Insignia, + .FirstOrDefault(), "มหาปรมาภรณ์ช้างเผือก"), PositionLevel = p.PosLevel == null ? "" : p.PosLevel, PositionType = p.PosType == null ? "" : p.PosType, @@ -6175,7 +6189,7 @@ namespace BMA.EHR.Application.Repositories .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) .OrderByDescending(x => x.Year) - .FirstOrDefault().Insignia, + .FirstOrDefault(), "ทวีติยาภรณ์ช้างเผือก"), PositionLevel = p.PosLevel == null ? "" : p.PosLevel, PositionType = p.PosType == null ? "" : p.PosType, @@ -6332,7 +6346,7 @@ namespace BMA.EHR.Application.Repositories .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) .OrderByDescending(x => x.Year) - .FirstOrDefault().Insignia, + .FirstOrDefault(), "ประถมาภรณ์มงกุฎไทย"), PositionLevel = p.PosLevel == null ? "" : p.PosLevel, PositionType = p.PosType == null ? "" : p.PosType, @@ -6560,7 +6574,7 @@ namespace BMA.EHR.Application.Repositories .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) .OrderByDescending(x => x.Year) - .FirstOrDefault().Insignia, + .FirstOrDefault(), "ประถมาภรณ์มงกุฎไทย"), PositionLevel = p.PosLevel == null ? "" : p.PosLevel, PositionType = p.PosType == null ? "" : p.PosType, @@ -6721,7 +6735,7 @@ namespace BMA.EHR.Application.Repositories .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) .OrderByDescending(x => x.Year) - .FirstOrDefault().Insignia, + .FirstOrDefault(), "ประถมาภรณ์ช้างเผือก"), PositionLevel = p.PosLevel == null ? "" : p.PosLevel, PositionType = p.PosType == null ? "" : p.PosType, @@ -6883,7 +6897,7 @@ namespace BMA.EHR.Application.Repositories .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) .OrderByDescending(x => x.Year) - .FirstOrDefault().Insignia, + .FirstOrDefault(), "มหาวชิรมงกุฎ"), PositionLevel = p.PosLevel == null ? "" : p.PosLevel, PositionType = p.PosType == null ? "" : p.PosType, @@ -7124,7 +7138,7 @@ namespace BMA.EHR.Application.Repositories .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) .OrderByDescending(x => x.Year) - .FirstOrDefault().Insignia, + .FirstOrDefault(), "ประถมาภรณ์มงกุฎไทย"), PositionLevel = p.PosLevel == null ? "" : p.PosLevel, PositionType = p.PosType == null ? "" : p.PosType, @@ -7285,7 +7299,7 @@ namespace BMA.EHR.Application.Repositories .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) .OrderByDescending(x => x.Year) - .FirstOrDefault().Insignia, + .FirstOrDefault(), "ประถมาภรณ์ช้างเผือก"), PositionLevel = p.PosLevel == null ? "" : p.PosLevel, PositionType = p.PosType == null ? "" : p.PosType, @@ -7446,7 +7460,7 @@ namespace BMA.EHR.Application.Repositories .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) .OrderByDescending(x => x.Year) - .FirstOrDefault().Insignia, + .FirstOrDefault(), "มหาวชิรมงกุฎ"), PositionLevel = p.PosLevel == null ? "" : p.PosLevel, PositionType = p.PosType == null ? "" : p.PosType, @@ -7658,7 +7672,7 @@ namespace BMA.EHR.Application.Repositories .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) .OrderByDescending(x => x.Year) - .FirstOrDefault().Insignia, + .FirstOrDefault(), "ประถมาภรณ์ช้างเผือก"), PositionLevel = p.PosLevel == null ? "" : p.PosLevel, PositionType = p.PosType == null ? "" : p.PosType, @@ -7825,7 +7839,7 @@ namespace BMA.EHR.Application.Repositories .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) .OrderByDescending(x => x.Year) - .FirstOrDefault().Insignia, + .FirstOrDefault(), "มหาวชิรมงกุฎ"), PositionLevel = p.PosLevel == null ? "" : p.PosLevel, PositionType = p.PosType == null ? "" : p.PosType, @@ -7992,7 +8006,7 @@ namespace BMA.EHR.Application.Repositories .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) .OrderByDescending(x => x.Year) - .FirstOrDefault().Insignia, + .FirstOrDefault(), "มหาปรมาภรณ์ช้างเผือก"), PositionLevel = p.PosLevel == null ? "" : p.PosLevel, PositionType = p.PosType == null ? "" : p.PosType,