fix issue : SIT ระบบบันทึกเวลาปฏิบัติงาน>>ลงเวลากรณีพิเศษ (ไม่มีแจ้งเตือนไปยังผู้บังคับบัญชา) #969
This commit is contained in:
parent
752b1a5479
commit
6afb95fe1b
3 changed files with 116 additions and 37 deletions
|
|
@ -73,47 +73,79 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
|
|||
|
||||
var userId = UserId != null ? Guid.Parse(UserId) : Guid.Empty;
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken ?? "");
|
||||
var profile_id = profile == null ? Guid.Empty : profile.Id;
|
||||
|
||||
var rootOc = _userProfileRepository.GetRootOcId(profile_id, AccessToken);
|
||||
var approver = string.Empty;
|
||||
var list = new List<OrganizationApproverResponse>();
|
||||
if (rootOc != null)
|
||||
// fix issue : SIT ระบบบันทึกเวลาปฏิบัติงาน>>ลงเวลากรณีพิเศษ (ไม่มีแจ้งเตือนไปยังผู้บังคับบัญชา) #969
|
||||
// send noti + inbox + mail
|
||||
// send inbox and notification
|
||||
var subject_str = $"มีการขออนุมัติลงเวลากรณีพิเศษ";
|
||||
var body_str = $"โปรดพิจารณาคำร้องขอลงเวลาในกรณีพิเศษจาก {profile.Prefix}{profile.FirstName} {profile.LastName} ในวันที่ {entity.CheckDate.Date.ToThaiShortDate2()}";
|
||||
|
||||
var subject = subject_str;
|
||||
var body = body_str;
|
||||
_emailSenderService.SendMail(subject, body, "dev@frappet.com");
|
||||
|
||||
|
||||
var inbox = new Inbox
|
||||
{
|
||||
list = await _commandRepository.GetOrgApproverAsync(rootOc ?? Guid.Empty);
|
||||
}
|
||||
if (list.Count > 0)
|
||||
Subject = subject_str,
|
||||
Body = body_str,
|
||||
ReceiverUserId = profile.CommanderId == Guid.Empty || profile.CommanderId == null ? Guid.Parse("08dbca3a-8b6a-4a4e-8b23-1f62e4f30ef6") : profile.CommanderId.Value,
|
||||
Payload = "",
|
||||
};
|
||||
_appContext.Set<Inbox>().Add(inbox);
|
||||
|
||||
var noti = new Notification
|
||||
{
|
||||
var appr = list.FirstOrDefault();
|
||||
|
||||
// send inbox and notification
|
||||
var subject_str = $"มีการขออนุมัติลงเวลากรณีพิเศษ";
|
||||
var body_str = $"โปรดพิจารณาคำร้องขอลงเวลาในกรณีพิเศษจาก {profile.Prefix}{profile.FirstName} {profile.LastName} ในวันที่ {entity.CheckDate.Date.ToThaiShortDate2()}";
|
||||
|
||||
var subject = subject_str;
|
||||
var body = body_str;
|
||||
_emailSenderService.SendMail(subject, body, "dev@frappet.com");
|
||||
Body = body_str,
|
||||
ReceiverUserId = profile.CommanderId == Guid.Empty || profile.CommanderId == null ? Guid.Parse("08dbca3a-8b6a-4a4e-8b23-1f62e4f30ef6") : profile.CommanderId.Value,
|
||||
Type = "",
|
||||
Payload = "",
|
||||
};
|
||||
_appContext.Set<Notification>().Add(noti);
|
||||
await _appContext.SaveChangesAsync();
|
||||
|
||||
|
||||
var inbox = new Inbox
|
||||
{
|
||||
Subject = subject_str,
|
||||
Body = body_str,
|
||||
ReceiverUserId = appr.Id == Guid.Empty ? Guid.Parse("08dbca3a-8b6a-4a4e-8b23-1f62e4f30ef6") : appr.Id,
|
||||
Payload = "",
|
||||
};
|
||||
_appContext.Set<Inbox>().Add(inbox);
|
||||
//var profile_id = profile == null ? Guid.Empty : profile.Id;
|
||||
|
||||
var noti = new Notification
|
||||
{
|
||||
Body = body_str,
|
||||
ReceiverUserId = appr.Id == Guid.Empty ? Guid.Parse("08dbca3a-8b6a-4a4e-8b23-1f62e4f30ef6") : appr.Id,
|
||||
Type = "",
|
||||
Payload = "",
|
||||
};
|
||||
_appContext.Set<Notification>().Add(noti);
|
||||
await _appContext.SaveChangesAsync();
|
||||
}
|
||||
//var rootOc = _userProfileRepository.GetRootOcId(profile_id, AccessToken);
|
||||
//var approver = string.Empty;
|
||||
//var list = new List<OrganizationApproverResponse>();
|
||||
//if (rootOc != null)
|
||||
//{
|
||||
// list = await _commandRepository.GetOrgApproverAsync(rootOc ?? Guid.Empty);
|
||||
//}
|
||||
//if (list.Count > 0)
|
||||
//{
|
||||
// var appr = list.FirstOrDefault();
|
||||
|
||||
// // send inbox and notification
|
||||
// var subject_str = $"มีการขออนุมัติลงเวลากรณีพิเศษ";
|
||||
// var body_str = $"โปรดพิจารณาคำร้องขอลงเวลาในกรณีพิเศษจาก {profile.Prefix}{profile.FirstName} {profile.LastName} ในวันที่ {entity.CheckDate.Date.ToThaiShortDate2()}";
|
||||
|
||||
// var subject = subject_str;
|
||||
// var body = body_str;
|
||||
// _emailSenderService.SendMail(subject, body, "dev@frappet.com");
|
||||
|
||||
|
||||
// var inbox = new Inbox
|
||||
// {
|
||||
// Subject = subject_str,
|
||||
// Body = body_str,
|
||||
// ReceiverUserId = appr.Id == Guid.Empty ? Guid.Parse("08dbca3a-8b6a-4a4e-8b23-1f62e4f30ef6") : appr.Id,
|
||||
// Payload = "",
|
||||
// };
|
||||
// _appContext.Set<Inbox>().Add(inbox);
|
||||
|
||||
// var noti = new Notification
|
||||
// {
|
||||
// Body = body_str,
|
||||
// ReceiverUserId = appr.Id == Guid.Empty ? Guid.Parse("08dbca3a-8b6a-4a4e-8b23-1f62e4f30ef6") : appr.Id,
|
||||
// Type = "",
|
||||
// Payload = "",
|
||||
// };
|
||||
// _appContext.Set<Notification>().Add(noti);
|
||||
// await _appContext.SaveChangesAsync();
|
||||
//}
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue