diff --git a/BMA.EHR.Application/Repositories/UserProfileRepository.cs b/BMA.EHR.Application/Repositories/UserProfileRepository.cs index 4f081f77..2d9ae7b4 100644 --- a/BMA.EHR.Application/Repositories/UserProfileRepository.cs +++ b/BMA.EHR.Application/Repositories/UserProfileRepository.cs @@ -233,6 +233,29 @@ namespace BMA.EHR.Application.Repositories throw; } } + + public async Task GetProfileByCheckInAsync(Guid keycloakId, string? accessToken) + { + try + { + var apiPath = $"{_configuration["API"]}/org/dotnet/check-keycloak/{keycloakId}"; + var apiKey = _configuration["API_KEY"]; + + var apiResult = await GetExternalAPIAsync(apiPath, accessToken ?? "", apiKey); + if (apiResult != null) + { + var raw = JsonConvert.DeserializeObject(apiResult); + if (raw != null) + return raw.Result; + } + + return null; + } + catch + { + throw; + } + } public async Task GetProfileLeaveByKeycloakIdAsync(Guid keycloakId, string? accessToken) diff --git a/BMA.EHR.Leave/Controllers/LeaveController.cs b/BMA.EHR.Leave/Controllers/LeaveController.cs index e5953e0b..e2a4010b 100644 --- a/BMA.EHR.Leave/Controllers/LeaveController.cs +++ b/BMA.EHR.Leave/Controllers/LeaveController.cs @@ -945,13 +945,13 @@ namespace BMA.EHR.Leave.Service.Controllers await _checkInJobStatusRepository.UpdateToProcessingAsync(taskId); } - var profile = await _userProfileRepository.GetProfileByKeycloakIdNew2Async(userId, data.Token); + var profile = await _userProfileRepository.GetProfileByCheckInAsync(userId, data.Token); if (profile == null) { - await _checkInJobStatusRepository.UpdateToFailedAsync(taskId, "เกิดข้อผิดพลาดจากการเรียก API [GetProfileByKeycloakIdNew2Async] : ไม่พบข้อมูลผู้ใช้"); + await _checkInJobStatusRepository.UpdateToFailedAsync(taskId, "เกิดข้อผิดพลาดจากการเรียก API [GetProfileByCheckInAsync] : ไม่พบข้อมูลผู้ใช้"); await _notificationService.SendNotificationAsync(data.Token, true, - "เกิดข้อผิดพลาดจากการเรียก API [GetProfileByKeycloakIdNew2Async] : ไม่พบข้อมูลผู้ใช้"); + "เกิดข้อผิดพลาดจากการเรียก API [GetProfileByCheckInAsync] : ไม่พบข้อมูลผู้ใช้"); //var staffList = await _userProfileRepository.GetOCStaffAsync(profile) return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound); }