From b1380d4a2f365058dee31a7d8e50045890b160cf Mon Sep 17 00:00:00 2001 From: moss <> Date: Tue, 27 May 2025 10:46:44 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=80=E0=B8=9E=E0=B8=B4=E0=B9=88=E0=B8=A1?= =?UTF-8?q?=E0=B8=A5=E0=B8=B9=E0=B8=81=E0=B8=88=E0=B9=89=E0=B8=B2=E0=B8=87?= =?UTF-8?q?=E0=B8=A5=E0=B8=87=E0=B8=97=E0=B8=B0=E0=B9=80=E0=B8=9A=E0=B8=B5?= =?UTF-8?q?=E0=B8=A2=E0=B8=99=E0=B9=80=E0=B8=84=E0=B8=A3=E0=B8=B7=E0=B9=88?= =?UTF-8?q?=E0=B8=AD=E0=B8=87=E0=B8=A3=E0=B8=B2=E0=B8=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Repositories/UserProfileRepository.cs | 19 +++ .../Insignias/PostProfileInsigniaDto.cs | 3 +- .../Controllers/InsigniaRequestController.cs | 117 +++++++++++++----- 3 files changed, 104 insertions(+), 35 deletions(-) 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); + } } } }