Enhance LeaveRequestController to restore profile checks and implement officer notification logic #2164
All checks were successful
Build & Deploy Leave Service / build (push) Successful in 1m34s
All checks were successful
Build & Deploy Leave Service / build (push) Successful in 1m34s
This commit is contained in:
parent
de91fd0fa2
commit
d70ed254c0
1 changed files with 25 additions and 6 deletions
|
|
@ -2323,12 +2323,31 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
await _leaveRequestRepository.SendToOfficerAsync(id);
|
await _leaveRequestRepository.SendToOfficerAsync(id);
|
||||||
|
|
||||||
// Remove Workflow Integration
|
// Remove Workflow Integration
|
||||||
// var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId);
|
var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId);
|
||||||
// var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken);
|
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken);
|
||||||
// if (profile == null)
|
if (profile == null)
|
||||||
// {
|
{
|
||||||
// return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
||||||
// }
|
}
|
||||||
|
|
||||||
|
// Get Officer List
|
||||||
|
var officers = await _userProfileRepository.GetOCStaffAsync(profile.Id, AccessToken);
|
||||||
|
if(officers != null && officers.Count > 0)
|
||||||
|
{
|
||||||
|
foreach (var officer in officers)
|
||||||
|
{
|
||||||
|
// Send Notification
|
||||||
|
var noti = new Notification
|
||||||
|
{
|
||||||
|
Body = $"มีคำร้องขอลาจาก {profile.Prefix}{profile.FirstName} {profile.LastName} รอรับการอนุมัติจากคุณ",
|
||||||
|
ReceiverUserId = officer.ProfileId,
|
||||||
|
Type = "",
|
||||||
|
Payload = $"{URL}/leave/detail/{id}",
|
||||||
|
};
|
||||||
|
_appDbContext.Set<Notification>().Add(noti);
|
||||||
|
}
|
||||||
|
await _appDbContext.SaveChangesAsync();
|
||||||
|
}
|
||||||
// var baseAPIOrg = _configuration["API"];
|
// var baseAPIOrg = _configuration["API"];
|
||||||
// var apiUrlOrg = $"{baseAPIOrg}/org/workflow/add-workflow";
|
// var apiUrlOrg = $"{baseAPIOrg}/org/workflow/add-workflow";
|
||||||
// if (profile.ProfileType == "OFFICER")
|
// if (profile.ProfileType == "OFFICER")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue