diff --git a/BMA.EHR.Leave/Controllers/LeaveRequestController.cs b/BMA.EHR.Leave/Controllers/LeaveRequestController.cs index 9233b374..09addc23 100644 --- a/BMA.EHR.Leave/Controllers/LeaveRequestController.cs +++ b/BMA.EHR.Leave/Controllers/LeaveRequestController.cs @@ -2247,47 +2247,46 @@ namespace BMA.EHR.Leave.Service.Controllers { await _leaveRequestRepository.SendToOfficerAsync(id); - // Remove Workflow Integration - // var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId); - // var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken); - // if (profile == null) - // { - // return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound); - // } - // var baseAPIOrg = _configuration["API"]; - // var apiUrlOrg = $"{baseAPIOrg}/org/workflow/add-workflow"; - // if (profile.ProfileType == "OFFICER") - // { - // using (var client = new HttpClient()) - // { - // client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken.Replace("Bearer ", "")); - // client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]); - // var _res = await client.PostAsJsonAsync(apiUrlOrg, new - // { - // refId = id, - // sysName = "SYS_LEAVE_LIST", - // posLevelName = profile.PosLevel ?? "", - // posTypeName = profile.PosType ?? "", - // fullName = $"{profile.Prefix}{profile.FirstName} {profile.LastName}" - // }); - // } - // } - // else - // { - // using (var client = new HttpClient()) - // { - // client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken.Replace("Bearer ", "")); - // client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]); - // var _res = await client.PostAsJsonAsync(apiUrlOrg, new - // { - // refId = id, - // sysName = "SYS_LEAVE_LIST_EMP", - // posLevelName = profile.PosLevel ?? "", - // posTypeName = profile.PosType ?? "", - // fullName = $"{profile.Prefix}{profile.FirstName} {profile.LastName}" - // }); - // } - // } + var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId); + var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken); + if (profile == null) + { + return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound); + } + var baseAPIOrg = _configuration["API"]; + var apiUrlOrg = $"{baseAPIOrg}/org/workflow/add-workflow"; + if (profile.ProfileType == "OFFICER") + { + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]); + var _res = await client.PostAsJsonAsync(apiUrlOrg, new + { + refId = id, + sysName = "SYS_LEAVE_LIST", + posLevelName = profile.PosLevel ?? "", + posTypeName = profile.PosType ?? "", + fullName = $"{profile.Prefix}{profile.FirstName} {profile.LastName}" + }); + } + } + else + { + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]); + var _res = await client.PostAsJsonAsync(apiUrlOrg, new + { + refId = id, + sysName = "SYS_LEAVE_LIST_EMP", + posLevelName = profile.PosLevel ?? "", + posTypeName = profile.PosType ?? "", + fullName = $"{profile.Prefix}{profile.FirstName} {profile.LastName}" + }); + } + } return Success(); }