fix issue #854 : ระบบลา (ลูกจ้างฯ) >> รายการขอลาไม่บันทึกในระบบทะเบียนประวัติ

This commit is contained in:
Bright 2024-12-11 12:13:33 +07:00
parent 2510009cc6
commit f1cb60aac8

View file

@ -553,7 +553,10 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
// }; // };
// _appDbContext.Set<ProfileLeave>().Add(profileLeave); // _appDbContext.Set<ProfileLeave>().Add(profileLeave);
var _baseAPI = _configuration["API"]; var _baseAPI = _configuration["API"];
var apiUrlSalary = $"{_baseAPI}/org/profile/leave"; var apiUrlSalary = string.Empty;
if (profile.ProfileType == "OFFICER")
{
apiUrlSalary = $"{_baseAPI}/org/profile/leave";
using (var client = new HttpClient()) using (var client = new HttpClient())
{ {
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken.Replace("Bearer ", "")); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken.Replace("Bearer ", ""));
@ -572,6 +575,32 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
}); });
// var _result = await _res.Content.ReadAsStringAsync(); // var _result = await _res.Content.ReadAsStringAsync();
} }
}
else if (profile.ProfileType == "EMPLOYEE")
{
apiUrlSalary = $"{_baseAPI}/org/profile-employee/leave";
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(apiUrlSalary, new
{
profileEmployeeId = profile.Id,
leaveTypeId = rawData?.Type?.Id ?? null,
dateLeaveStart = rawData.LeaveStartDate,
dateLeaveEnd = rawData.LeaveEndDate,
totalLeave = 0,
leaveCount = 0,
leaveDays = rawData.LeaveTotal,
status = "approve",
reason = rawData.LeaveDetail,
});
}
}
else
{
throw new Exception("ไม่สามารถทำรายการได้");
}
await _appDbContext.SaveChangesAsync(); await _appDbContext.SaveChangesAsync();
// insert to process timestamp // insert to process timestamp