ตอนกดขอยกเลิกส่ง noti
- ตอนผู้ยื่นกดขอยกเลิกแจ้งมาที่ผู้มีอำนาจ - ผู้มีอำนาจอนุมัติหรือไม่อนุมัติ แจ้งผู้ยื่น และผู้บังคับบัญชาที่มีใน list
This commit is contained in:
parent
7e3ae58b33
commit
40babdf1a7
2 changed files with 70 additions and 3 deletions
|
|
@ -633,11 +633,11 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
throw new Exception("ไม่สามารถอัพเดตการยกเลิกรายการลาไปยังระบบทะเบียนประวัติ");
|
||||
//var _result = await _res.Content.ReadAsStringAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: remove วันลา
|
||||
|
||||
// Send Noti
|
||||
// Send Noti หาเจ้าของใบลา
|
||||
var noti = new Notification
|
||||
{
|
||||
Body = $"การขอยกเลิกใบลาของคุณได้รับการอนุมัติ",
|
||||
|
|
@ -646,6 +646,25 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
Payload = "",
|
||||
};
|
||||
_appDbContext.Set<Notification>().Add(noti);
|
||||
|
||||
var commanders = rawData.Approvers
|
||||
.Where(x => x.ApproveType!.ToUpper() == "COMMANDER")
|
||||
.OrderBy(x => x.Seq)
|
||||
.ToList();
|
||||
|
||||
foreach(var commander in commanders)
|
||||
{
|
||||
var noti1 = new Notification
|
||||
{
|
||||
Body = $"การขอยกเลิกใบลาของ {rawData.FirstName} {rawData.LastName} ได้รับการอนุมัติแล้ว",
|
||||
ReceiverUserId = commander.ProfileId,
|
||||
Type = "",
|
||||
Payload = "",
|
||||
};
|
||||
_appDbContext.Set<Notification>().Add(noti1);
|
||||
}
|
||||
|
||||
|
||||
await _appDbContext.SaveChangesAsync();
|
||||
|
||||
|
||||
|
|
@ -708,6 +727,25 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
Payload = "",
|
||||
};
|
||||
_appDbContext.Set<Notification>().Add(noti);
|
||||
|
||||
var commanders = rawData.Approvers
|
||||
.Where(x => x.ApproveType!.ToUpper() == "COMMANDER")
|
||||
.OrderBy(x => x.Seq)
|
||||
.ToList();
|
||||
|
||||
foreach (var commander in commanders)
|
||||
{
|
||||
var noti1 = new Notification
|
||||
{
|
||||
Body = $"การขอยกเลิกใบลาของ {rawData.FirstName} {rawData.LastName} ไม่ได้รับการอนุมัติ \r\nเนืองจาก {Reason}",
|
||||
ReceiverUserId = commander.ProfileId,
|
||||
Type = "",
|
||||
Payload = "",
|
||||
};
|
||||
_appDbContext.Set<Notification>().Add(noti1);
|
||||
}
|
||||
|
||||
|
||||
await _appDbContext.SaveChangesAsync();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ using BMA.EHR.Domain.Common;
|
|||
using BMA.EHR.Domain.Extensions;
|
||||
using BMA.EHR.Domain.Models.Leave.Commons;
|
||||
using BMA.EHR.Domain.Models.Leave.Requests;
|
||||
using BMA.EHR.Domain.Models.Notifications;
|
||||
using BMA.EHR.Domain.Shared;
|
||||
using BMA.EHR.Infrastructure.Persistence;
|
||||
using BMA.EHR.Leave.Service.DTOs.LeaveRequest;
|
||||
|
|
@ -35,6 +36,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
#region " Fields "
|
||||
|
||||
private readonly LeaveDbContext _context;
|
||||
private readonly ApplicationDBContext _appDbContext;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly IWebHostEnvironment _hostingEnvironment;
|
||||
private readonly IConfiguration _configuration;
|
||||
|
|
@ -54,6 +56,8 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
private const string APPROVE_STEP_APPROVE = "st4";
|
||||
private const string APPROVE_STEP_REJECT = "st5";
|
||||
|
||||
private readonly string URL = string.Empty;
|
||||
|
||||
#endregion
|
||||
|
||||
#region " Constuctor and Destructor "
|
||||
|
|
@ -70,7 +74,8 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
CommandRepository commandRepository,
|
||||
UserCalendarRepository userCalendarRepository,
|
||||
PermissionRepository permission,
|
||||
LeaveBeginningRepository leaveBeginningRepository)
|
||||
LeaveBeginningRepository leaveBeginningRepository,
|
||||
ApplicationDBContext appDbContext)
|
||||
{
|
||||
_context = context;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
|
|
@ -85,6 +90,9 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
_userCalendarRepository = userCalendarRepository;
|
||||
_permission = permission;
|
||||
_leaveBeginningRepository = leaveBeginningRepository;
|
||||
_appDbContext = appDbContext;
|
||||
|
||||
URL = (_configuration["VITE_URL_MGT"]).Replace("/api/v1", "");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
@ -1726,6 +1734,27 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
// save to database
|
||||
await _leaveRequestRepository.UpdateWithTrackingAsync(data);
|
||||
|
||||
|
||||
// TODO: Send notification to 1st Commander
|
||||
var approvers = data.Approvers
|
||||
.Where(x => x.ApproveType!.ToUpper() == "APPROVER")
|
||||
.OrderBy(x => x.Seq)
|
||||
.ToList();
|
||||
|
||||
foreach(var approver in approvers)
|
||||
{
|
||||
// Send Notification
|
||||
var noti1 = new Notification
|
||||
{
|
||||
Body = $"การขอลาของคุณ {data.FirstName} {data.LastName} รอรับการอนุมัติจากคุณ",
|
||||
ReceiverUserId = approver!.ProfileId,
|
||||
Type = "",
|
||||
Payload = $"{URL}/leave/detail/{id}",
|
||||
};
|
||||
_appDbContext.Set<Notification>().Add(noti1);
|
||||
}
|
||||
|
||||
|
||||
return Success();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue