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,
|
||||
[FromBody] LeaveRequestApproveDto req)
|
||||
{
|
||||
await _leaveRequestRepository.SendToOfficerAsync(id);
|
||||
try
|
||||
{
|
||||
await _leaveRequestRepository.SendToOfficerAsync(id);
|
||||
|
||||
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())
|
||||
var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId);
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken);
|
||||
if (profile == null)
|
||||
{
|
||||
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}"
|
||||
});
|
||||
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
using (var client = new HttpClient())
|
||||
var baseAPIOrg = _configuration["API"];
|
||||
var apiUrlOrg = $"{baseAPIOrg}/org/workflow/add-workflow";
|
||||
if (profile.ProfileType == "OFFICER")
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken.Replace("Bearer ", ""));
|
||||
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
refId = id,
|
||||
sysName = "SYS_LEAVE_LIST_EMP",
|
||||
posLevelName = "EMP",
|
||||
posTypeName = "EMP",
|
||||
});
|
||||
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 = "EMP",
|
||||
posTypeName = "EMP",
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Success();
|
||||
return Success();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Error(ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -1984,7 +1991,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
var extendLeave = 0.0;
|
||||
var leaveLimit = rawData.Type.Limit;
|
||||
|
||||
var approvePrevYear = await _leaveRequestRepository.GetSumApproveLeaveAsync(thisYear - 1);
|
||||
var approvePrevYear = await _leaveRequestRepository.GetSumApproveLeaveAsync(thisYear - 1);
|
||||
|
||||
if (rawData.Type.Code == "LV-005")
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue