เพิ่ม Param leaveId และ เรียก api ยกเลิกการลาในทะเบียนประวัติ #1492
This commit is contained in:
parent
249911b931
commit
42bdb66440
1 changed files with 39 additions and 2 deletions
|
|
@ -308,7 +308,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
return await rawData.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<List<LeaveRequest>> GetLeaveRequestForAdminWithAuthAsync(int year, Guid type, string status, DateTime startDate, DateTime endDate,List<Guid> keycloakIdList)
|
||||
public async Task<List<LeaveRequest>> GetLeaveRequestForAdminWithAuthAsync(int year, Guid type, string status, DateTime startDate, DateTime endDate, List<Guid> keycloakIdList)
|
||||
{
|
||||
var rawData = _dbContext.Set<LeaveRequest>().AsNoTracking()
|
||||
.Include(x => x.Type)
|
||||
|
|
@ -452,7 +452,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
return await rawData.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<LeaveRequest> ApproveCancelLeaveRequestAsync(LeaveRequest data, string Reason,string LeaveReason)
|
||||
public async Task<LeaveRequest> ApproveCancelLeaveRequestAsync(LeaveRequest data, string Reason, string LeaveReason)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -482,6 +482,24 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
_appDbContext.Set<Notification>().Add(noti);
|
||||
await _appDbContext.SaveChangesAsync();
|
||||
|
||||
|
||||
var _baseAPI = _configuration["API"];
|
||||
var apiUrlSalary = $"{_baseAPI}/org/profile/leave/cancel/{data.Id}";
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken.Replace("Bearer ", ""));
|
||||
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||
|
||||
var request = new HttpRequestMessage(HttpMethod.Patch, apiUrlSalary);
|
||||
|
||||
// ส่ง request
|
||||
var _res = await client.SendAsync(request);
|
||||
if (!_res.IsSuccessStatusCode)
|
||||
throw new Exception("ไม่สามารถอัพเดตการยกเลิกรายการลาไปยังระบบทะเบียนประวัติ");
|
||||
//var _result = await _res.Content.ReadAsStringAsync();
|
||||
}
|
||||
|
||||
|
||||
return data;
|
||||
}
|
||||
catch
|
||||
|
|
@ -527,6 +545,23 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
};
|
||||
_appDbContext.Set<Notification>().Add(noti);
|
||||
await _appDbContext.SaveChangesAsync();
|
||||
|
||||
var _baseAPI = _configuration["API"];
|
||||
var apiUrlSalary = $"{_baseAPI}/org/profile/leave/cancel/{rawData.Id}";
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken.Replace("Bearer ", ""));
|
||||
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||
|
||||
var request = new HttpRequestMessage(HttpMethod.Patch, apiUrlSalary);
|
||||
|
||||
// ส่ง request
|
||||
var _res = await client.SendAsync(request);
|
||||
if (!_res.IsSuccessStatusCode)
|
||||
throw new Exception("ไม่สามารถอัพเดตการยกเลิกรายการลาไปยังระบบทะเบียนประวัติ");
|
||||
//var _result = await _res.Content.ReadAsStringAsync();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public async Task RejectCancelLeaveRequestAsync(Guid id, string Reason)
|
||||
|
|
@ -939,6 +974,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
leaveDays = rawData.LeaveTotal,
|
||||
status = "approve",
|
||||
reason = rawData.LeaveDetail,
|
||||
leaveId = rawData.Id,
|
||||
});
|
||||
// var _result = await _res.Content.ReadAsStringAsync();
|
||||
}
|
||||
|
|
@ -961,6 +997,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
leaveDays = rawData.LeaveTotal,
|
||||
status = "approve",
|
||||
reason = rawData.LeaveDetail,
|
||||
leaveId = rawData.Id,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue