diff --git a/BMA.EHR.Application/Repositories/UserProfileRepository.cs b/BMA.EHR.Application/Repositories/UserProfileRepository.cs index ab7436e7..d59794e6 100644 --- a/BMA.EHR.Application/Repositories/UserProfileRepository.cs +++ b/BMA.EHR.Application/Repositories/UserProfileRepository.cs @@ -1051,6 +1051,25 @@ namespace BMA.EHR.Application.Repositories } + public async Task PostProfileEmpInsigniaAsync(PostProfileInsigniaDto body, string? accessToken) + { + try + { + var apiPath = $"{_configuration["API"]}/org/profile-employee/insignia"; + var apiKey = _configuration["API_KEY"]; + + var profiles = new List(); + + var apiResult = await PostExternalAPIBooleanAsync(apiPath, accessToken ?? "", body, apiKey); + + } + catch + { + throw; + } + + } + public async Task GetIsOfficerRootAsync(string? accessToken, string sys) { try diff --git a/BMA.EHR.Application/Responses/Insignias/PostProfileInsigniaDto.cs b/BMA.EHR.Application/Responses/Insignias/PostProfileInsigniaDto.cs index 5677f667..5ac913fa 100644 --- a/BMA.EHR.Application/Responses/Insignias/PostProfileInsigniaDto.cs +++ b/BMA.EHR.Application/Responses/Insignias/PostProfileInsigniaDto.cs @@ -2,7 +2,8 @@ { public class PostProfileInsigniaDto { - public Guid profileId { get; set; } + public Guid? profileId { get; set; } + public Guid? profileEmployeeId { get; set; } public int year { get; set; } = 0; diff --git a/BMA.EHR.Insignia/Controllers/InsigniaRequestController.cs b/BMA.EHR.Insignia/Controllers/InsigniaRequestController.cs index 951d90b9..82197af6 100644 --- a/BMA.EHR.Insignia/Controllers/InsigniaRequestController.cs +++ b/BMA.EHR.Insignia/Controllers/InsigniaRequestController.cs @@ -1798,25 +1798,50 @@ namespace BMA.EHR.Insignia.Service.Controllers { insigniaNoteProfile.Status = "DONE"; - var profileInsigniaBody = new PostProfileInsigniaDto + if (profile.ProfileType == "OFFICER") { - profileId = profile.Id, - year = insigniaNote.Year, - no = req.No, - volumeNo = req.VolumeNo, - section = req.Section, - page = req.Page, - receiveDate = req.DateReceive.Value, - dateAnnounce = req.Date.Value, - insigniaId = insignia.Id, - issue = req.Issue, - note = "", - refCommandDate = null, - refCommandNo = "", - volume = "", + var profileInsigniaBody = new PostProfileInsigniaDto + { + profileId = profile.Id, + year = insigniaNote.Year, + no = req.No, + volumeNo = req.VolumeNo, + section = req.Section, + page = req.Page, + receiveDate = req.DateReceive.Value, + dateAnnounce = req.Date.Value, + insigniaId = insignia.Id, + issue = req.Issue, + note = "", + refCommandDate = null, + refCommandNo = "", + volume = "", - }; - await _userProfileRepository.PostProfileInsigniaAsync(profileInsigniaBody, AccessToken); + }; + await _userProfileRepository.PostProfileInsigniaAsync(profileInsigniaBody, AccessToken); + } + else + { + var profileInsigniaBody = new PostProfileInsigniaDto + { + profileEmployeeId = profile.Id, + year = insigniaNote.Year, + no = req.No, + volumeNo = req.VolumeNo, + section = req.Section, + page = req.Page, + receiveDate = req.DateReceive.Value, + dateAnnounce = req.Date.Value, + insigniaId = insignia.Id, + issue = req.Issue, + note = "", + refCommandDate = null, + refCommandNo = "", + volume = "", + + }; + await _userProfileRepository.PostProfileEmpInsigniaAsync(profileInsigniaBody, AccessToken); + } } } else @@ -1841,24 +1866,48 @@ namespace BMA.EHR.Insignia.Service.Controllers if (req.DateReceive != null && req.Date != null) { profileInsignia.Status = "DONE"; - var profileInsigniaBody = new PostProfileInsigniaDto + if (profile.ProfileType == "OFFICER") { - profileId = profileInsignia.ProfileId.Value, - year = insigniaNote.Year, - no = profileInsignia.No, - volumeNo = profileInsignia.VolumeNo, - section = profileInsignia.Section, - page = profileInsignia.Page, - receiveDate = profileInsignia.DateReceive.Value, - dateAnnounce = profileInsignia.Date.Value, - insigniaId = profileInsignia.RequestInsignia.Id, - issue = profileInsignia.Issue, - note = "", - refCommandDate = null, - refCommandNo = "", - volume = "", - }; - await _userProfileRepository.PostProfileInsigniaAsync(profileInsigniaBody, AccessToken); + var profileInsigniaBody = new PostProfileInsigniaDto + { + profileId = profileInsignia.ProfileId.Value, + year = insigniaNote.Year, + no = profileInsignia.No, + volumeNo = profileInsignia.VolumeNo, + section = profileInsignia.Section, + page = profileInsignia.Page, + receiveDate = profileInsignia.DateReceive.Value, + dateAnnounce = profileInsignia.Date.Value, + insigniaId = profileInsignia.RequestInsignia.Id, + issue = profileInsignia.Issue, + note = "", + refCommandDate = null, + refCommandNo = "", + volume = "", + }; + await _userProfileRepository.PostProfileInsigniaAsync(profileInsigniaBody, AccessToken); + } + else + { + var profileInsigniaBody = new PostProfileInsigniaDto + { + profileEmployeeId = profileInsignia.ProfileId.Value, + year = insigniaNote.Year, + no = profileInsignia.No, + volumeNo = profileInsignia.VolumeNo, + section = profileInsignia.Section, + page = profileInsignia.Page, + receiveDate = profileInsignia.DateReceive.Value, + dateAnnounce = profileInsignia.Date.Value, + insigniaId = profileInsignia.RequestInsignia.Id, + issue = profileInsignia.Issue, + note = "", + refCommandDate = null, + refCommandNo = "", + volume = "", + }; + await _userProfileRepository.PostProfileEmpInsigniaAsync(profileInsigniaBody, AccessToken); + } } } }