fix #1337
This commit is contained in:
parent
2730ac9174
commit
56501b5bcd
1 changed files with 44 additions and 37 deletions
|
|
@ -1816,49 +1816,56 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
public async Task<ActionResult<ResponseObject>> SendLeaveRequestAsync(Guid id,
|
public async Task<ActionResult<ResponseObject>> SendLeaveRequestAsync(Guid id,
|
||||||
[FromBody] LeaveRequestApproveDto req)
|
[FromBody] LeaveRequestApproveDto req)
|
||||||
{
|
{
|
||||||
await _leaveRequestRepository.SendToOfficerAsync(id);
|
try
|
||||||
|
{
|
||||||
|
await _leaveRequestRepository.SendToOfficerAsync(id);
|
||||||
|
|
||||||
var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId);
|
var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId);
|
||||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken);
|
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken);
|
||||||
if (profile == null)
|
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 ", ""));
|
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
||||||
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}"
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
var baseAPIOrg = _configuration["API"];
|
||||||
else
|
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 ", ""));
|
using (var client = new HttpClient())
|
||||||
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
|
||||||
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
|
||||||
{
|
{
|
||||||
refId = id,
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken.Replace("Bearer ", ""));
|
||||||
sysName = "SYS_LEAVE_LIST_EMP",
|
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||||
posLevelName = "EMP",
|
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
||||||
posTypeName = "EMP",
|
{
|
||||||
});
|
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 = "EMP",
|
||||||
|
posTypeName = "EMP",
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return Success();
|
return Success();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return Error(ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue