Merge branch 'develop' of github.com:Frappet/BMA-EHR-BackEnd into develop
This commit is contained in:
commit
57e1cee038
1 changed files with 45 additions and 16 deletions
|
|
@ -553,24 +553,53 @@ 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;
|
||||||
using (var client = new HttpClient())
|
if (profile.ProfileType == "OFFICER")
|
||||||
{
|
{
|
||||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken.Replace("Bearer ", ""));
|
apiUrlSalary = $"{_baseAPI}/org/profile/leave";
|
||||||
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
using (var client = new HttpClient())
|
||||||
var _res = await client.PostAsJsonAsync(apiUrlSalary, new
|
|
||||||
{
|
{
|
||||||
profileId = profile.Id,
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken.Replace("Bearer ", ""));
|
||||||
leaveTypeId = rawData?.Type?.Id ?? null,
|
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||||
dateLeaveStart = rawData.LeaveStartDate,
|
var _res = await client.PostAsJsonAsync(apiUrlSalary, new
|
||||||
dateLeaveEnd = rawData.LeaveEndDate,
|
{
|
||||||
totalLeave = 0,//หน้า fe ไม่ได้ใช้
|
profileId = profile.Id,
|
||||||
leaveCount = 0,//หน้า fe ไม่ได้ใช้
|
leaveTypeId = rawData?.Type?.Id ?? null,
|
||||||
leaveDays = rawData.LeaveTotal,
|
dateLeaveStart = rawData.LeaveStartDate,
|
||||||
status = "approve",
|
dateLeaveEnd = rawData.LeaveEndDate,
|
||||||
reason = rawData.LeaveDetail,
|
totalLeave = 0,//หน้า fe ไม่ได้ใช้
|
||||||
});
|
leaveCount = 0,//หน้า fe ไม่ได้ใช้
|
||||||
// var _result = await _res.Content.ReadAsStringAsync();
|
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();
|
await _appDbContext.SaveChangesAsync();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue