From e5f6a44f5f696a3f30bdcc72279c306622881a2f Mon Sep 17 00:00:00 2001 From: Suphonchai Phoonsawat Date: Fri, 15 May 2026 16:04:39 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=80=E0=B8=9E=E0=B8=B4=E0=B9=88=E0=B8=A1?= =?UTF-8?q?=20Call=20API=20GetProfileByCheckInAsync=20=E0=B9=83=E0=B8=8A?= =?UTF-8?q?=E0=B9=89=E0=B9=81=E0=B8=97=E0=B8=99=E0=B8=82=E0=B8=AD=E0=B8=87?= =?UTF-8?q?=E0=B9=80=E0=B8=94=E0=B8=B4=E0=B8=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Repositories/UserProfileRepository.cs | 23 +++++++++++++++++++ BMA.EHR.Leave/Controllers/LeaveController.cs | 6 ++--- 2 files changed, 26 insertions(+), 3 deletions(-) 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); }