เพิี่มขั้นตอนการอนุมัติใบลา โดยดึงข้อมูลจากตาราง approver
This commit is contained in:
parent
ddc3d268be
commit
e635e4ff61
2 changed files with 339 additions and 128 deletions
|
|
@ -510,6 +510,10 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
|
||||
public async Task CommanderApproveLeaveRequest(Guid id, string reason)
|
||||
{
|
||||
// Get UserId from token
|
||||
var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId);
|
||||
|
||||
|
||||
var rawData = await GetByIdAsync(id);
|
||||
if (rawData == null)
|
||||
{
|
||||
|
|
@ -518,18 +522,117 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
|
||||
if (rawData.ApproveStep != "st2")
|
||||
{
|
||||
throw new Exception("คำขอนี้ยังไม่ได้รับการอนุมัติจากเจ้าหน้าที่ ไม่สามารถทำรายการได้");
|
||||
throw new Exception("คำขอนี้ยังไม่ได้อยู่ในขั้นตอนที่สามารถอนุมัติได้ ไม่สามารถทำรายการได้");
|
||||
}
|
||||
|
||||
rawData.LeaveStatus = "PENDING";
|
||||
rawData.LeaveComment = reason;
|
||||
rawData.ApproveStep = "st3";
|
||||
// check commander approve
|
||||
var approvers = rawData.Approvers.Where(x => x.ApproveType!.ToUpper() == "COMMANDER").OrderBy(x => x.Seq).ToList();
|
||||
var maxSeq = approvers.Max(x => x.Seq);
|
||||
|
||||
var approver = approvers.FirstOrDefault(x => x.KeycloakId == userId);
|
||||
if (approver == null)
|
||||
{
|
||||
throw new Exception("คุณไม่มีสิทธิ์อนุมัติการลาในขั้นตอนนี้");
|
||||
}
|
||||
|
||||
approver.ApproveStatus = "APPROVE";
|
||||
approver.Comment = reason;
|
||||
|
||||
if (approver.Seq != maxSeq)
|
||||
{
|
||||
|
||||
|
||||
var nextApprover = approvers.FirstOrDefault(x => x.Seq == approver.Seq + 1);
|
||||
// Send Noti
|
||||
var noti = new Notification
|
||||
{
|
||||
Body = $"การขอลาของคุณ {rawData.FirstName} {rawData.LastName} รอรับการอนุมัติจากคุณ",
|
||||
ReceiverUserId = nextApprover!.ProfileId,
|
||||
Type = "",
|
||||
Payload = "",
|
||||
};
|
||||
_appDbContext.Set<Notification>().Add(noti);
|
||||
await _appDbContext.SaveChangesAsync();
|
||||
|
||||
rawData.LeaveStatus = "PENDING";
|
||||
await UpdateAsync(rawData);
|
||||
}
|
||||
else
|
||||
{
|
||||
rawData.LeaveStatus = "PENDING";
|
||||
rawData.LeaveComment = reason;
|
||||
rawData.ApproveStep = "st3";
|
||||
|
||||
await UpdateAsync(rawData);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public async Task CommanderRejectLeaveRequest(Guid id, string reason)
|
||||
{
|
||||
// Get UserId from token
|
||||
var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId);
|
||||
|
||||
|
||||
var rawData = await GetByIdAsync(id);
|
||||
if (rawData == null)
|
||||
{
|
||||
throw new Exception(GlobalMessages.DataNotFound);
|
||||
}
|
||||
|
||||
if (rawData.ApproveStep != "st2")
|
||||
{
|
||||
throw new Exception("คำขอนี้ยังไม่ได้อยู่ในขั้นตอนที่สามารถอนุมัติได้ ไม่สามารถทำรายการได้");
|
||||
}
|
||||
|
||||
// check commander approve
|
||||
var approvers = rawData.Approvers.Where(x => x.ApproveType!.ToUpper() == "COMMANDER").OrderBy(x => x.Seq).ToList();
|
||||
var maxSeq = approvers.Max(x => x.Seq);
|
||||
|
||||
var approver = approvers.FirstOrDefault(x => x.KeycloakId == userId);
|
||||
if (approver == null)
|
||||
{
|
||||
throw new Exception("คุณไม่มีสิทธิ์อนุมัติการลาในขั้นตอนนี้");
|
||||
}
|
||||
|
||||
approver.ApproveStatus = "REJECT";
|
||||
approver.Comment = reason;
|
||||
|
||||
if (approver.Seq != maxSeq)
|
||||
{
|
||||
|
||||
|
||||
var nextApprover = approvers.FirstOrDefault(x => x.Seq == approver.Seq + 1);
|
||||
// Send Noti
|
||||
var noti = new Notification
|
||||
{
|
||||
Body = $"การขอลาของคุณ {rawData.FirstName} {rawData.LastName} รอรับการอนุมัติจากคุณ",
|
||||
ReceiverUserId = nextApprover!.ProfileId,
|
||||
Type = "",
|
||||
Payload = "",
|
||||
};
|
||||
_appDbContext.Set<Notification>().Add(noti);
|
||||
await _appDbContext.SaveChangesAsync();
|
||||
|
||||
rawData.LeaveStatus = "PENDING";
|
||||
await UpdateAsync(rawData);
|
||||
}
|
||||
else
|
||||
{
|
||||
rawData.LeaveStatus = "PENDING";
|
||||
rawData.LeaveComment = reason;
|
||||
rawData.ApproveStep = "st3";
|
||||
|
||||
await UpdateAsync(rawData);
|
||||
}
|
||||
|
||||
await UpdateAsync(rawData);
|
||||
}
|
||||
|
||||
public async Task ApproveLeaveRequest(Guid id, string reason)
|
||||
{
|
||||
// Get UserId from token
|
||||
var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId);
|
||||
|
||||
var rawData = await GetByIdAsync(id);
|
||||
if (rawData == null)
|
||||
{
|
||||
|
|
@ -538,107 +641,125 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
|
||||
if (rawData.ApproveStep != "st3")
|
||||
{
|
||||
throw new Exception("คำขอนี้ยังไม่ได้รับการอนุมัติจากผู้บังคับบัญชา ไม่สามารถทำรายการได้");
|
||||
throw new Exception("คำขอนี้ยังไม่ได้อยู่ในขั้นตอนที่สามารถอนุมัติได้ ไม่สามารถทำรายการได้");
|
||||
}
|
||||
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId, AccessToken);
|
||||
if (profile == null)
|
||||
// check commander approve
|
||||
var approvers = rawData.Approvers.Where(x => x.ApproveType!.ToUpper() == "APPROVER").OrderBy(x => x.Seq).ToList();
|
||||
var maxSeq = approvers.Max(x => x.Seq);
|
||||
|
||||
var approver = approvers.FirstOrDefault(x => x.KeycloakId == userId);
|
||||
if (approver == null)
|
||||
{
|
||||
throw new Exception(GlobalMessages.DataNotFound);
|
||||
throw new Exception("คุณไม่มีสิทธิ์อนุมัติการลาในขั้นตอนนี้");
|
||||
}
|
||||
|
||||
rawData.LeaveStatus = "APPROVE";
|
||||
rawData.LeaveDirectorComment = reason;
|
||||
rawData.ApproveStep = "st4";
|
||||
approver.ApproveStatus = "APPROVE";
|
||||
approver.Comment = reason;
|
||||
|
||||
await UpdateAsync(rawData);
|
||||
|
||||
//var leaveType = await _appDbContext.Set<TypeLeave>()
|
||||
// .FirstOrDefaultAsync(x => x.Name == rawData.Type.Name);
|
||||
|
||||
|
||||
// insert to profile leave
|
||||
// var profileLeave = new ProfileLeave
|
||||
// {
|
||||
// DateStartLeave = rawData.LeaveStartDate,
|
||||
// DateEndLeave = rawData.LeaveEndDate,
|
||||
|
||||
// TotalLeave = rawData.LeaveTotal,
|
||||
// Status = "approve",
|
||||
// Reason = rawData.LeaveDetail,
|
||||
|
||||
// ProfileId = profile.Id, // change from profile object to id
|
||||
// TypeLeave = leaveType
|
||||
// };
|
||||
// _appDbContext.Set<ProfileLeave>().Add(profileLeave);
|
||||
var _baseAPI = _configuration["API"];
|
||||
var apiUrlSalary = string.Empty;
|
||||
if (profile.ProfileType == "OFFICER")
|
||||
if (approver.Seq != maxSeq)
|
||||
{
|
||||
apiUrlSalary = $"{_baseAPI}/org/profile/leave";
|
||||
using (var client = new HttpClient())
|
||||
var nextApprover = approvers.FirstOrDefault(x => x.Seq == approver.Seq + 1);
|
||||
// Send Noti
|
||||
var noti1 = new Notification
|
||||
{
|
||||
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,
|
||||
});
|
||||
}
|
||||
Body = $"การขอลาของคุณ {rawData.FirstName} {rawData.LastName} รอรับการอนุมัติจากคุณ",
|
||||
ReceiverUserId = nextApprover!.ProfileId,
|
||||
Type = "",
|
||||
Payload = "",
|
||||
};
|
||||
_appDbContext.Set<Notification>().Add(noti1);
|
||||
await _appDbContext.SaveChangesAsync();
|
||||
|
||||
await UpdateAsync(rawData);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("ไม่สามารถทำรายการได้");
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId, AccessToken);
|
||||
if (profile == null)
|
||||
{
|
||||
throw new Exception(GlobalMessages.DataNotFound);
|
||||
}
|
||||
|
||||
rawData.LeaveStatus = "APPROVE";
|
||||
rawData.LeaveDirectorComment = reason;
|
||||
rawData.ApproveStep = "st4";
|
||||
|
||||
await UpdateAsync(rawData);
|
||||
|
||||
var _baseAPI = _configuration["API"];
|
||||
var apiUrlSalary = string.Empty;
|
||||
if (profile.ProfileType == "OFFICER")
|
||||
{
|
||||
apiUrlSalary = $"{_baseAPI}/org/profile/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
|
||||
{
|
||||
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();
|
||||
|
||||
// insert to process timestamp
|
||||
|
||||
|
||||
// Send Noti
|
||||
var noti = new Notification
|
||||
{
|
||||
Body = $"การขอลาของคุณได้รับการอนุมัติ",
|
||||
ReceiverUserId = profile.Id,
|
||||
Type = "",
|
||||
Payload = "",
|
||||
};
|
||||
_appDbContext.Set<Notification>().Add(noti);
|
||||
await _appDbContext.SaveChangesAsync();
|
||||
}
|
||||
await _appDbContext.SaveChangesAsync();
|
||||
|
||||
// insert to process timestamp
|
||||
|
||||
|
||||
// Send Noti
|
||||
var noti = new Notification
|
||||
{
|
||||
Body = $"การขอลาของคุณได้รับการอนุมัติ",
|
||||
ReceiverUserId = profile.Id,
|
||||
Type = "",
|
||||
Payload = "",
|
||||
};
|
||||
_appDbContext.Set<Notification>().Add(noti);
|
||||
await _appDbContext.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task RejectLeaveRequest(Guid id, string reason)
|
||||
{
|
||||
// Get UserId from token
|
||||
var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId);
|
||||
|
||||
var rawData = await GetByIdAsync(id);
|
||||
if (rawData == null)
|
||||
{
|
||||
|
|
@ -647,31 +768,63 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
|
||||
if (rawData.ApproveStep != "st3")
|
||||
{
|
||||
throw new Exception("คำขอนี้ยังไม่ได้รับการอนุมัติจากผู้บังคับบัญชา ไม่สามารถทำรายการได้");
|
||||
throw new Exception("คำขอนี้ยังไม่ได้อยู่ในขั้นตอนที่สามารถอนุมัติได้ ไม่สามารถทำรายการได้");
|
||||
}
|
||||
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId, AccessToken);
|
||||
if (profile == null)
|
||||
// check commander approve
|
||||
var approvers = rawData.Approvers.Where(x => x.ApproveType!.ToUpper() == "APPROVER").OrderBy(x => x.Seq).ToList();
|
||||
var maxSeq = approvers.Max(x => x.Seq);
|
||||
|
||||
var approver = approvers.FirstOrDefault(x => x.KeycloakId == userId);
|
||||
if (approver == null)
|
||||
{
|
||||
throw new Exception(GlobalMessages.DataNotFound);
|
||||
throw new Exception("คุณไม่มีสิทธิ์อนุมัติการลาในขั้นตอนนี้");
|
||||
}
|
||||
|
||||
rawData.LeaveStatus = "REJECT";
|
||||
rawData.LeaveDirectorComment = reason;
|
||||
rawData.ApproveStep = "st5";
|
||||
approver.ApproveStatus = "REJECT";
|
||||
approver.Comment = reason;
|
||||
|
||||
await UpdateAsync(rawData);
|
||||
|
||||
// Send Noti
|
||||
var noti = new Notification
|
||||
if (approver.Seq != maxSeq)
|
||||
{
|
||||
Body = $"การขอลาของคุณไม่ได้รับการอนุมัติ \r\nเนื่องจาก{reason}",
|
||||
ReceiverUserId = profile.Id,
|
||||
Type = "",
|
||||
Payload = "",
|
||||
};
|
||||
_appDbContext.Set<Notification>().Add(noti);
|
||||
await _appDbContext.SaveChangesAsync();
|
||||
var nextApprover = approvers.FirstOrDefault(x => x.Seq == approver.Seq + 1);
|
||||
// Send Noti
|
||||
var noti1 = new Notification
|
||||
{
|
||||
Body = $"การขอลาของคุณ {rawData.FirstName} {rawData.LastName} รอรับการอนุมัติจากคุณ",
|
||||
ReceiverUserId = nextApprover!.ProfileId,
|
||||
Type = "",
|
||||
Payload = "",
|
||||
};
|
||||
_appDbContext.Set<Notification>().Add(noti1);
|
||||
await _appDbContext.SaveChangesAsync();
|
||||
|
||||
await UpdateAsync(rawData);
|
||||
}
|
||||
else
|
||||
{
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId, AccessToken);
|
||||
if (profile == null)
|
||||
{
|
||||
throw new Exception(GlobalMessages.DataNotFound);
|
||||
}
|
||||
|
||||
rawData.LeaveStatus = "REJECT";
|
||||
rawData.LeaveDirectorComment = reason;
|
||||
rawData.ApproveStep = "st5";
|
||||
|
||||
await UpdateAsync(rawData);
|
||||
|
||||
// Send Noti
|
||||
var noti = new Notification
|
||||
{
|
||||
Body = $"การขอลาของคุณไม่ได้รับการอนุมัติ \r\nเนื่องจาก{reason}",
|
||||
ReceiverUserId = profile.Id,
|
||||
Type = "",
|
||||
Payload = "",
|
||||
};
|
||||
_appDbContext.Set<Notification>().Add(noti);
|
||||
await _appDbContext.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<List<GetSumApproveLeaveByTypeDto>> GetSumSendLeaveAsync(int year)
|
||||
|
|
|
|||
|
|
@ -1815,15 +1815,57 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
public async Task<ActionResult<ResponseObject>> CommanderApproveLeaveRequestAsync(Guid id,
|
||||
[FromBody] LeaveRequestApproveDto req)
|
||||
{
|
||||
var getPermission = await _permission.GetPermissionAPIAsync("UPDATE", "SYS_LEAVE_LIST");
|
||||
var jsonData = JsonConvert.DeserializeObject<JObject>(getPermission);
|
||||
if (jsonData["status"]?.ToString() != "200")
|
||||
try
|
||||
{
|
||||
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||
}
|
||||
await _leaveRequestRepository.CommanderApproveLeaveRequest(id, req.Reason ?? "");
|
||||
var getPermission = await _permission.GetPermissionAPIAsync("UPDATE", "SYS_LEAVE_LIST");
|
||||
var jsonData = JsonConvert.DeserializeObject<JObject>(getPermission);
|
||||
if (jsonData["status"]?.ToString() != "200")
|
||||
{
|
||||
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||
}
|
||||
await _leaveRequestRepository.CommanderApproveLeaveRequest(id, req.Reason ?? "");
|
||||
|
||||
return Success();
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
return Error(ex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ผู้บังคับบัญชาไม่อนุมัติการลา(ADMIN)
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// </returns>
|
||||
/// <response code="200">เมื่อทำรายการสำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPut("admin/reject/comander/{id:guid}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> CommanderRejectLeaveRequestAsync(Guid id,
|
||||
[FromBody] LeaveRequestApproveDto req)
|
||||
{
|
||||
try
|
||||
{
|
||||
var getPermission = await _permission.GetPermissionAPIAsync("UPDATE", "SYS_LEAVE_LIST");
|
||||
var jsonData = JsonConvert.DeserializeObject<JObject>(getPermission);
|
||||
if (jsonData["status"]?.ToString() != "200")
|
||||
{
|
||||
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||
}
|
||||
await _leaveRequestRepository.CommanderRejectLeaveRequest(id, req.Reason ?? "");
|
||||
|
||||
return Success();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Error(ex);
|
||||
}
|
||||
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -1841,15 +1883,23 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
public async Task<ActionResult<ResponseObject>> ApproveLeaveRequestAsync(Guid id,
|
||||
[FromBody] LeaveRequestApproveDto req)
|
||||
{
|
||||
var getPermission = await _permission.GetPermissionAPIAsync("UPDATE", "SYS_LEAVE_LIST");
|
||||
var jsonData = JsonConvert.DeserializeObject<JObject>(getPermission);
|
||||
if (jsonData["status"]?.ToString() != "200")
|
||||
try
|
||||
{
|
||||
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||
}
|
||||
await _leaveRequestRepository.ApproveLeaveRequest(id, req.Reason ?? "");
|
||||
var getPermission = await _permission.GetPermissionAPIAsync("UPDATE", "SYS_LEAVE_LIST");
|
||||
var jsonData = JsonConvert.DeserializeObject<JObject>(getPermission);
|
||||
if (jsonData["status"]?.ToString() != "200")
|
||||
{
|
||||
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||
}
|
||||
await _leaveRequestRepository.ApproveLeaveRequest(id, req.Reason ?? "");
|
||||
|
||||
return Success();
|
||||
return Success();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Error(ex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -1934,15 +1984,23 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
public async Task<ActionResult<ResponseObject>> RejectLeaveRequestAsync(Guid id,
|
||||
[FromBody] LeaveRequestApproveDto req)
|
||||
{
|
||||
var getPermission = await _permission.GetPermissionAPIAsync("UPDATE", "SYS_LEAVE_LIST");
|
||||
var jsonData = JsonConvert.DeserializeObject<JObject>(getPermission);
|
||||
if (jsonData["status"]?.ToString() != "200")
|
||||
try
|
||||
{
|
||||
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||
}
|
||||
await _leaveRequestRepository.RejectLeaveRequest(id, req.Reason ?? "");
|
||||
var getPermission = await _permission.GetPermissionAPIAsync("UPDATE", "SYS_LEAVE_LIST");
|
||||
var jsonData = JsonConvert.DeserializeObject<JObject>(getPermission);
|
||||
if (jsonData["status"]?.ToString() != "200")
|
||||
{
|
||||
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||
}
|
||||
await _leaveRequestRepository.RejectLeaveRequest(id, req.Reason ?? "");
|
||||
|
||||
return Success();
|
||||
return Success();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Error(ex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue