Merge branch 'develop' of github.com:Frappet/BMA-EHR-BackEnd into develop
Some checks failed
release-dev / release-dev (push) Failing after 11s

This commit is contained in:
kittapath 2024-12-12 00:00:55 +07:00
commit 12448ba0a4

View file

@ -553,24 +553,53 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
// };
// _appDbContext.Set<ProfileLeave>().Add(profileLeave);
var _baseAPI = _configuration["API"];
var apiUrlSalary = $"{_baseAPI}/org/profile/leave";
using (var client = new HttpClient())
var apiUrlSalary = string.Empty;
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(apiUrlSalary, new
apiUrlSalary = $"{_baseAPI}/org/profile/leave";
using (var client = new HttpClient())
{
profileId = profile.Id,
leaveTypeId = rawData?.Type?.Id ?? null,
dateLeaveStart = rawData.LeaveStartDate,
dateLeaveEnd = rawData.LeaveEndDate,
totalLeave = 0,//หน้า fe ไม่ได้ใช้
leaveCount = 0,//หน้า fe ไม่ได้ใช้
leaveDays = rawData.LeaveTotal,
status = "approve",
reason = rawData.LeaveDetail,
});
// var _result = await _res.Content.ReadAsStringAsync();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken.Replace("Bearer ", ""));
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _res = await client.PostAsJsonAsync(apiUrlSalary, new
{
profileId = profile.Id,
leaveTypeId = rawData?.Type?.Id ?? null,
dateLeaveStart = rawData.LeaveStartDate,
dateLeaveEnd = rawData.LeaveEndDate,
totalLeave = 0,//หน้า fe ไม่ได้ใช้
leaveCount = 0,//หน้า fe ไม่ได้ใช้
leaveDays = rawData.LeaveTotal,
status = "approve",
reason = rawData.LeaveDetail,
});
// 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();