diff --git a/BMA.EHR.Application/Repositories/InsigniaPeriodsRepository.cs b/BMA.EHR.Application/Repositories/InsigniaPeriodsRepository.cs index 7edb2d48..9117eed6 100644 --- a/BMA.EHR.Application/Repositories/InsigniaPeriodsRepository.cs +++ b/BMA.EHR.Application/Repositories/InsigniaPeriodsRepository.cs @@ -287,8 +287,8 @@ namespace BMA.EHR.Application.Repositories .Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) .OrderByDescending(x => x.Order).FirstOrDefault().Amount : p.Amount, - PositionSalaryAmount = p.PositionSalaryAmount, - Amount = p.Amount, + PositionSalaryAmount = p.PositionSalaryAmount ?? 0, + Amount = p.Amount ?? 0, RootId = p.RootId, Root = p.Root, }); @@ -322,8 +322,8 @@ namespace BMA.EHR.Application.Repositories LastInsignia = p.LastInsignia, LastInsigniaId = p.LastInsigniaId, Salary = p.Salary, - PositionSalaryAmount = p.PositionSalaryAmount, - Amount = p.Amount, + PositionSalaryAmount = p.PositionSalaryAmount ?? 0, + Amount = p.Amount ?? 0, RootId = p.RootId, Root = p.Root, RequestInsignia = GetInsigniaByName("เบญจมาภรณ์มงกุฎไทย"), @@ -380,8 +380,8 @@ namespace BMA.EHR.Application.Repositories PositionTypeId = p.PosTypeId, PositionTypeName = p.PosType, Gender = p.Gender ?? "", - PositionSalaryAmount = p.PositionSalaryAmount, - Amount = p.Amount, + PositionSalaryAmount = p.PositionSalaryAmount ?? 0, + Amount = p.Amount ?? 0, RootId = p.RootId, Root = p.Root, LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 @@ -511,8 +511,8 @@ namespace BMA.EHR.Application.Repositories .FirstOrDefault() == null ? 0 : p.ProfileInsignia.Where(x => x.InsigniaId.Value == bcmRoyal.Id).OrderBy(x => x.Year) .FirstOrDefault().Year, - PositionSalaryAmount = p.PositionSalaryAmount, - Amount = p.Amount, + PositionSalaryAmount = p.PositionSalaryAmount ?? 0, + Amount = p.Amount ?? 0, RootId = p.RootId, Root = p.Root, }) @@ -684,8 +684,8 @@ namespace BMA.EHR.Application.Repositories .Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) .OrderByDescending(x => x.Order).FirstOrDefault().Amount : p.Amount, - PositionSalaryAmount = p.PositionSalaryAmount, - Amount = p.Amount, + PositionSalaryAmount = p.PositionSalaryAmount ?? 0, + Amount = p.Amount ?? 0, RootId = p.RootId, Root = p.Root, }); @@ -800,8 +800,8 @@ namespace BMA.EHR.Application.Repositories .FirstOrDefault() == null ? 0 : p.ProfileInsignia.Where(x => x.InsigniaId.Value == bcpRoyal.Id).OrderBy(x => x.Year) .FirstOrDefault().Year, - PositionSalaryAmount = p.PositionSalaryAmount, - Amount = p.Amount, + PositionSalaryAmount = p.PositionSalaryAmount ?? 0, + Amount = p.Amount ?? 0, RootId = p.RootId, Root = p.Root, }) @@ -831,8 +831,8 @@ namespace BMA.EHR.Application.Repositories RequestInsignia = GetInsigniaByName("จัตุรถาภรณ์มงกุฎไทย"), Seq = 2, Gender = p.Gender, - PositionSalaryAmount = p.PositionSalaryAmount, - Amount = p.Amount, + PositionSalaryAmount = p.PositionSalaryAmount ?? 0, + Amount = p.Amount ?? 0, RootId = p.RootId, Root = p.Root, MatchingConditions = new List @@ -935,8 +935,8 @@ namespace BMA.EHR.Application.Repositories RequestInsignia = GetInsigniaByName("จัตุรถาภรณ์ช้างเผือก"), Seq = 2, Gender = p.Gender, - PositionSalaryAmount = p.PositionSalaryAmount, - Amount = p.Amount, + PositionSalaryAmount = p.PositionSalaryAmount ?? 0, + Amount = p.Amount ?? 0, RootId = p.RootId, Root = p.Root, MatchingConditions = new List @@ -6529,8 +6529,9 @@ namespace BMA.EHR.Application.Repositories var result_candidate = new List(); var allOfficerProfilesByRoot = (await _userProfileRepository.GetOfficerProfileByRootIdAsync(ocId, AccessToken)); - //var allEmployeeProfileByRoot = - // (await _userProfileRepository.GetEmployeeProfileByRootIdAsync(ocId, AccessToken)); + + var allEmployeeProfileByRoot = + (await _userProfileRepository.GetEmployeeProfileByRootIdAsync(ocId, AccessToken)); var type_coin = await GetCoinCandidate(periodId, ocId, allOfficerProfilesByRoot); var type1_level1 = await GetInsigniaCandidate_Type1_Level1(periodId, ocId, allOfficerProfilesByRoot); @@ -6550,6 +6551,10 @@ namespace BMA.EHR.Application.Repositories var type4_level10 = await GetInsigniaCandidate_Type4_Level10(periodId, ocId, allOfficerProfilesByRoot); var type4_level11 = await GetInsigniaCandidate_Type4_Level11(periodId, ocId, allOfficerProfilesByRoot); + + var employee_type1 = await GetEmployeeInsignia_Type1(periodId, ocId, allEmployeeProfileByRoot); + var employee_type2 = await GetEmployeeInsignia_Type2(periodId, ocId, allEmployeeProfileByRoot); + // union result foreach (var r in type_coin) { @@ -6656,20 +6661,19 @@ namespace BMA.EHR.Application.Repositories result_candidate.Add(r); } - // TODO : Remove for Test Error - //foreach (var r in employee_type2) - //{ - // var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId); - // if (old == null) - // result_candidate.Add(r); - //} + foreach (var r in employee_type2) + { + var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId); + if (old == null) + result_candidate.Add(r); + } - //foreach (var r in employee_type1) - //{ - // var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId); - // if (old == null) - // result_candidate.Add(r); - //} + foreach (var r in employee_type1) + { + var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId); + if (old == null) + result_candidate.Add(r); + } //foreach (var r in type)