diff --git a/BMA.EHR.Application/Repositories/InsigniaPeriodsRepository.cs b/BMA.EHR.Application/Repositories/InsigniaPeriodsRepository.cs index cfade76e..42d7ede9 100644 --- a/BMA.EHR.Application/Repositories/InsigniaPeriodsRepository.cs +++ b/BMA.EHR.Application/Repositories/InsigniaPeriodsRepository.cs @@ -8868,48 +8868,44 @@ namespace BMA.EHR.Application.Repositories } } - public async Task UpdateInsigniaRequestProfile(string[] items, string type, Guid? periodId) + public async Task UpdateInsigniaRequestProfile(string[] items, string type) { try { - if (type.Trim().ToUpper() == "OFFICER") + var allProfiles = await _userProfileRepository.GetInsigniaRequestsProfileAsync(items, type, AccessToken); + + if (allProfiles != null && allProfiles.Count > 0) { - var allProfiles = await _userProfileRepository.GetInsigniaRequestsProfileAsync(items, type, AccessToken); + var insigniaRequestProfiles = await _dbContext.Set() + .Where(x => allProfiles.Select(x => x.Id).ToList().Contains(x.ProfileId)) + .ToListAsync(); - if (allProfiles != null && allProfiles.Count > 0) + foreach (var insigniaRequestProfile in insigniaRequestProfiles) { - var insigniaRequestProfiles = await _dbContext.Set() - .Where(x => allProfiles.Select(x => x.Id).ToList().Contains(x.ProfileId)) - .ToListAsync(); + var profile = allProfiles.FirstOrDefault(p => p.Id == insigniaRequestProfile.ProfileId); - foreach (var insigniaRequestProfile in insigniaRequestProfiles) + if (profile != null) { - var profile = allProfiles.FirstOrDefault(p => p.Id == insigniaRequestProfile.ProfileId); - - if (profile != null) - { - insigniaRequestProfile.MarkDiscipline = profile?.MarkDiscipline; - insigniaRequestProfile.MarkLeave = profile?.MarkLeave; - insigniaRequestProfile.MarkRate = profile?.MarkRate; - insigniaRequestProfile.MarkInsignia = profile?.MarkInsignia; - } + insigniaRequestProfile.MarkDiscipline = profile?.MarkDiscipline; + insigniaRequestProfile.MarkLeave = profile?.MarkLeave; + insigniaRequestProfile.MarkRate = profile?.MarkRate; + insigniaRequestProfile.MarkInsignia = profile?.MarkInsignia; + insigniaRequestProfile.APR1 = profile?.APR1; + insigniaRequestProfile.APR2 = profile?.APR2; + insigniaRequestProfile.APR3 = profile?.APR3; + insigniaRequestProfile.APR4 = profile?.APR4; + insigniaRequestProfile.APR5 = profile?.APR5; + insigniaRequestProfile.OCT1 = profile?.OCT1; + insigniaRequestProfile.OCT2 = profile?.OCT2; + insigniaRequestProfile.OCT3 = profile?.OCT3; + insigniaRequestProfile.OCT4 = profile?.OCT4; + insigniaRequestProfile.OCT5 = profile?.OCT5; + insigniaRequestProfile.LastUpdateFullName = FullName ?? "System Administrator"; + insigniaRequestProfile.LastUpdateUserId = UserId ?? ""; + insigniaRequestProfile.LastUpdatedAt = DateTime.Now; } } } - //else if (type.Trim().ToUpper() == "EMPLOYEE" && periodId != null) - //{ - // var insigniaRequests = await _dbContext.Set() - // .Where(x => x.Period.Id == periodId) - // .ToListAsync(); - - // var allEmpProfileIds = new List(); - // foreach (var insigniaRequest in insigniaRequests) - // { - // var orgRootId = insigniaRequest.Id.ToString(); - // var allEmpProfiles = await _userProfileRepository.GetInsigniaRequestsProfileEmpAsync(items, orgRootId, AccessToken); - // } - - //} await _dbContext.SaveChangesAsync(); diff --git a/BMA.EHR.Application/Responses/Profiles/GetMarkStatusDto.cs b/BMA.EHR.Application/Responses/Profiles/GetMarkStatusDto.cs index d419089d..1828762b 100644 --- a/BMA.EHR.Application/Responses/Profiles/GetMarkStatusDto.cs +++ b/BMA.EHR.Application/Responses/Profiles/GetMarkStatusDto.cs @@ -8,16 +8,16 @@ public bool? MarkRate { get; set; } = false; public bool? MarkInsignia { get; set; } = false; - public string? Apr1 { get; set; } - public string? Apr2 { get; set; } - public string? Apr3 { get; set; } - public string? Apr4 { get; set; } - public string? Apr5 { get; set; } + public string? APR1 { get; set; } + public string? APR2 { get; set; } + public string? APR3 { get; set; } + public string? APR4 { get; set; } + public string? APR5 { get; set; } - public string? Oct1 { get; set; } - public string? Oct2 { get; set; } - public string? Oct3 { get; set; } - public string? Oct4 { get; set; } - public string? Oct5 { get; set; } + public string? OCT1 { get; set; } + public string? OCT2 { get; set; } + public string? OCT3 { get; set; } + public string? OCT4 { get; set; } + public string? OCT5 { get; set; } } } diff --git a/BMA.EHR.Insignia/Controllers/InsigniaRequestController.cs b/BMA.EHR.Insignia/Controllers/InsigniaRequestController.cs index 1979fa45..951d90b9 100644 --- a/BMA.EHR.Insignia/Controllers/InsigniaRequestController.cs +++ b/BMA.EHR.Insignia/Controllers/InsigniaRequestController.cs @@ -2728,28 +2728,39 @@ namespace BMA.EHR.Insignia.Service.Controllers if (insigniaPeriod.InsigniaRequests.Count > 0) { - var allProfileIds = new List(); + //var allProfileIds = new List(); + //var allProfileEmpIds = new List(); foreach (var InsigniaRequest in insigniaPeriod.InsigniaRequests) { var profiles = await _context.Set() .Where(p => p.Request.Id == InsigniaRequest.Id && p.ProfileType.Trim().ToUpper() == "OFFICER").Select(x => x.ProfileId.ToString()).ToListAsync(); - if (profiles != null && profiles.Count > 0) + var profileEmps = await _context.Set() + .Where(p => p.Request.Id == InsigniaRequest.Id && p.ProfileType.Trim().ToUpper() == "EMPLOYEE").Select(x => x.ProfileId.ToString()).ToListAsync(); + + if (profiles.Count > 0) { - allProfileIds.AddRange(profiles); + //allProfileIds.AddRange(profiles); + await _insigniaPeriodRepository.UpdateInsigniaRequestProfile(profiles.ToArray(), "OFFICER"); + } + + if (profileEmps.Count > 0) + { + //allProfileEmpIds.AddRange(profileEmps); + await _insigniaPeriodRepository.UpdateInsigniaRequestProfile(profileEmps.ToArray(), "EMPLOYEE"); } } - if (allProfileIds.Count > 0) - { - await _insigniaPeriodRepository.UpdateInsigniaRequestProfile(allProfileIds.ToArray(), "OFFICER", null); - } - } + //if (allProfileIds.Count > 0) + //{ + // await _insigniaPeriodRepository.UpdateInsigniaRequestProfile(allProfileIds.ToArray(), "OFFICER"); + //} - //if (insigniaPeriod.InsigniaEmployees.Count > 0) - //{ - // await _insigniaPeriodRepository.UpdateInsigniaRequestProfile(insigniaPeriod.InsigniaEmployees.Select(x => x.RefId!.ValueOrBlank()).ToArray(), "EMPLOYEE", insigniaPeriod.Id); - //} + //if (allProfileEmpIds.Count > 0) + //{ + // await _insigniaPeriodRepository.UpdateInsigniaRequestProfile(allProfileEmpIds.ToArray(), "EMPLOYEE"); + //} + } return Success(); }