แก้noti

This commit is contained in:
Kittapath 2024-08-05 14:33:30 +07:00
parent c802ab718f
commit 8c540b6568
3 changed files with 84 additions and 54 deletions

View file

@ -64,7 +64,7 @@ namespace BMA.EHR.Application.Repositories.MessageQueue
if (org == null || org.result == null) if (org == null || org.result == null)
return new List<InboxResponse>(); return new List<InboxResponse>();
profileId = org.result.rootId == null ? "" : org.result.profileId; profileId = org.result.profileId == null ? "" : org.result.profileId;
} }
if (profileId == null || profileId == "") if (profileId == null || profileId == "")
return new List<InboxResponse>(); return new List<InboxResponse>();

View file

@ -68,7 +68,7 @@ namespace BMA.EHR.Application.Repositories.MessageQueue
if (org == null || org.result == null) if (org == null || org.result == null)
return new List<InboxResponse>(); return new List<InboxResponse>();
profileId = org.result.rootId == null ? "" : org.result.profileId; profileId = org.result.profileId == null ? "" : org.result.profileId;
} }
if (profileId == null || profileId == "") if (profileId == null || profileId == "")
return new List<InboxResponse>(); return new List<InboxResponse>();
@ -143,7 +143,7 @@ namespace BMA.EHR.Application.Repositories.MessageQueue
if (org == null || org.result == null) if (org == null || org.result == null)
return 0; return 0;
profileId = org.result.rootId == null ? "" : org.result.profileId; profileId = org.result.profileId == null ? "" : org.result.profileId;
} }
if (profileId == null || profileId == "") if (profileId == null || profileId == "")
return 0; return 0;
@ -190,11 +190,26 @@ namespace BMA.EHR.Application.Repositories.MessageQueue
// var profile = await _dbContext.Set<Profile>().FirstOrDefaultAsync(x => x.Id == ReceiverUserId); // var profile = await _dbContext.Set<Profile>().FirstOrDefaultAsync(x => x.Id == ReceiverUserId);
//if (profile != null) //if (profile != null)
//{ //{
_dbContext.Set<Notification>().Add(new Notification _dbContext.Set<Notification>().Add(new Notification
{
Body = Body,
ReceiverUserId = ReceiverUserId,
Type = "",
Payload = Payload,
CreatedFullName = FullName ?? "System Administrator",
CreatedUserId = UserId ?? "",
CreatedAt = DateTime.Now,
LastUpdateFullName = FullName ?? "System Administrator",
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
});
if (IsSendInbox == true)
{
_dbContext.Set<Inbox>().Add(new Inbox
{ {
Subject = Subject,
Body = Body, Body = Body,
ReceiverUserId = ReceiverUserId, ReceiverUserId = ReceiverUserId,
Type = "",
Payload = Payload, Payload = Payload,
CreatedFullName = FullName ?? "System Administrator", CreatedFullName = FullName ?? "System Administrator",
CreatedUserId = UserId ?? "", CreatedUserId = UserId ?? "",
@ -203,27 +218,12 @@ namespace BMA.EHR.Application.Repositories.MessageQueue
LastUpdateUserId = UserId ?? "", LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now, LastUpdatedAt = DateTime.Now,
}); });
if (IsSendInbox == true) }
{ if (IsSendMail == true)
_dbContext.Set<Inbox>().Add(new Inbox {
{ _emailSenderService.SendMail(Subject, Body, "kittapath@frappet.com");
Subject = Subject, }
Body = Body, await _dbContext.SaveChangesAsync();
ReceiverUserId = ReceiverUserId,
Payload = Payload,
CreatedFullName = FullName ?? "System Administrator",
CreatedUserId = UserId ?? "",
CreatedAt = DateTime.Now,
LastUpdateFullName = FullName ?? "System Administrator",
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
});
}
if (IsSendMail == true)
{
_emailSenderService.SendMail(Subject, Body, "kittapath@frappet.com");
}
await _dbContext.SaveChangesAsync();
//} //}
} }
catch catch

View file

@ -492,7 +492,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
} }
} }
await _repositoryNoti.PushNotificationAsync( await _repositoryNoti.PushNotificationAsync(
Guid.Parse("aec26ac3-417c-4cf9-9cbe-874939f99ecc"), Guid.Parse("08dc3db9-257d-470d-8256-3dc24f6fa332"),
$"{retirementResign.prefix}{retirementResign.firstName} {retirementResign.lastName} ได้ทำการยื่นขอลาออก", $"{retirementResign.prefix}{retirementResign.firstName} {retirementResign.lastName} ได้ทำการยื่นขอลาออก",
$"{retirementResign.prefix}{retirementResign.firstName} {retirementResign.lastName} ได้ทำการยื่นขอลาออก", $"{retirementResign.prefix}{retirementResign.firstName} {retirementResign.lastName} ได้ทำการยื่นขอลาออก",
"", "",
@ -638,9 +638,39 @@ namespace BMA.EHR.Retirement.Service.Controllers
} }
else else
{ {
updated.Status = "CANCEL"; updated.Status = "CANCEL";
} }
if (updated.OfficerReject != null)
{
await _repositoryNoti.PushNotificationAsync(
Guid.Parse("08dc3db9-257d-470d-8256-3dc24f6fa332"),
$"คำขอลาออกของ {updated.prefix}{updated.firstName} {updated.lastName} ได้ทำการขอยกเลิก",
$"คำขอลาออกของ {updated.prefix}{updated.firstName} {updated.lastName} ได้ทำการขอยกเลิก",
"",
true
);
}
if (updated.CommanderReject != null)
{
await _repositoryNoti.PushNotificationAsync(
Guid.Parse("08dc432c-2bc5-4b81-8089-9c057c51192c"),
$"คำขอลาออกของ {updated.prefix}{updated.firstName} {updated.lastName} ได้ทำการขอยกเลิก",
$"คำขอลาออกของ {updated.prefix}{updated.firstName} {updated.lastName} ได้ทำการขอยกเลิก",
"",
true
);
}
if (updated.OligarchReject != null)
{
await _repositoryNoti.PushNotificationAsync(
Guid.Parse("08dc4307-0adc-4bcd-8213-5479bb010236"),
$"คำขอลาออกของ {updated.prefix}{updated.firstName} {updated.lastName} ได้ทำการขอยกเลิก",
$"คำขอลาออกของ {updated.prefix}{updated.firstName} {updated.lastName} ได้ทำการขอยกเลิก",
"",
true
);
}
updated.CancelReason = req.Reason; updated.CancelReason = req.Reason;
updated.LastUpdateFullName = FullName ?? "System Administrator"; updated.LastUpdateFullName = FullName ?? "System Administrator";
updated.LastUpdateUserId = UserId ?? ""; updated.LastUpdateUserId = UserId ?? "";
@ -752,8 +782,8 @@ namespace BMA.EHR.Retirement.Service.Controllers
updated.LastUpdatedAt = DateTime.Now; updated.LastUpdatedAt = DateTime.Now;
await _repositoryNoti.PushNotificationAsync( await _repositoryNoti.PushNotificationAsync(
Guid.Parse("08dc432c-2bc5-4b81-8089-9c057c51192c"), Guid.Parse("08dc432c-2bc5-4b81-8089-9c057c51192c"),
$"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ได้รับการอนุมัติจากการเจ้าหน้าที่", $"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ได้รับการอนุมัติจากการเจ้าหน้าที่",
$"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ได้รับการอนุมัติจากการเจ้าหน้าที่", $"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ได้รับการอนุมัติจากการเจ้าหน้าที่",
"", "",
true true
); );
@ -761,8 +791,8 @@ namespace BMA.EHR.Retirement.Service.Controllers
{ {
await _repositoryNoti.PushNotificationAsync( await _repositoryNoti.PushNotificationAsync(
Guid.Parse(updated.profileId), Guid.Parse(updated.profileId),
$"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ได้รับการอนุมัติจากการเจ้าหน้าที่", $"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ได้รับการอนุมัติจากการเจ้าหน้าที่",
$"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ได้รับการอนุมัติจากการเจ้าหน้าที่", $"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ได้รับการอนุมัติจากการเจ้าหน้าที่",
"", "",
true true
); );
@ -799,8 +829,8 @@ namespace BMA.EHR.Retirement.Service.Controllers
updated.LastUpdatedAt = DateTime.Now; updated.LastUpdatedAt = DateTime.Now;
await _repositoryNoti.PushNotificationAsync( await _repositoryNoti.PushNotificationAsync(
Guid.Parse("08dc432c-2bc5-4b81-8089-9c057c51192c"), Guid.Parse("08dc432c-2bc5-4b81-8089-9c057c51192c"),
$"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ถูกยับยั้งจากการเจ้าหน้าที่", $"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ถูกยับยั้งจากการเจ้าหน้าที่",
$"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ถูกยับยั้งจากการเจ้าหน้าที่", $"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ถูกยับยั้งจากการเจ้าหน้าที่",
"", "",
true true
); );
@ -808,8 +838,8 @@ namespace BMA.EHR.Retirement.Service.Controllers
{ {
await _repositoryNoti.PushNotificationAsync( await _repositoryNoti.PushNotificationAsync(
Guid.Parse(updated.profileId), Guid.Parse(updated.profileId),
$"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ถูกยับยั้งจากการเจ้าหน้าที่", $"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ถูกยับยั้งจากการเจ้าหน้าที่",
$"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ถูกยับยั้งจากการเจ้าหน้าที่", $"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ถูกยับยั้งจากการเจ้าหน้าที่",
"", "",
true true
); );
@ -844,8 +874,8 @@ namespace BMA.EHR.Retirement.Service.Controllers
updated.LastUpdatedAt = DateTime.Now; updated.LastUpdatedAt = DateTime.Now;
await _repositoryNoti.PushNotificationAsync( await _repositoryNoti.PushNotificationAsync(
Guid.Parse("08dc4307-0adc-4bcd-8213-5479bb010236"), Guid.Parse("08dc4307-0adc-4bcd-8213-5479bb010236"),
$"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ได้รับการอนุมัติจากผู้บังคับบัญชา", $"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ได้รับการอนุมัติจากผู้บังคับบัญชา",
$"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ได้รับการอนุมัติจากผู้บังคับบัญชา", $"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ได้รับการอนุมัติจากผู้บังคับบัญชา",
"", "",
true true
); );
@ -853,8 +883,8 @@ namespace BMA.EHR.Retirement.Service.Controllers
{ {
await _repositoryNoti.PushNotificationAsync( await _repositoryNoti.PushNotificationAsync(
Guid.Parse(updated.profileId), Guid.Parse(updated.profileId),
$"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ได้รับการอนุมัติจากผู้บังคับบัญชา", $"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ได้รับการอนุมัติจากผู้บังคับบัญชา",
$"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ได้รับการอนุมัติจากผู้บังคับบัญชา", $"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ได้รับการอนุมัติจากผู้บังคับบัญชา",
"", "",
true true
); );
@ -891,8 +921,8 @@ namespace BMA.EHR.Retirement.Service.Controllers
updated.LastUpdatedAt = DateTime.Now; updated.LastUpdatedAt = DateTime.Now;
await _repositoryNoti.PushNotificationAsync( await _repositoryNoti.PushNotificationAsync(
Guid.Parse("08dc4307-0adc-4bcd-8213-5479bb010236"), Guid.Parse("08dc4307-0adc-4bcd-8213-5479bb010236"),
$"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ถูกยับยั้งจากผู้บังคับบัญชา", $"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ถูกยับยั้งจากผู้บังคับบัญชา",
$"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ถูกยับยั้งจากผู้บังคับบัญชา", $"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ถูกยับยั้งจากผู้บังคับบัญชา",
"", "",
true true
); );
@ -900,8 +930,8 @@ namespace BMA.EHR.Retirement.Service.Controllers
{ {
await _repositoryNoti.PushNotificationAsync( await _repositoryNoti.PushNotificationAsync(
Guid.Parse(updated.profileId), Guid.Parse(updated.profileId),
$"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ถูกยับยั้งจากผู้บังคับบัญชา", $"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ถูกยับยั้งจากผู้บังคับบัญชา",
$"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ถูกยับยั้งจากผู้บังคับบัญชา", $"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ถูกยับยั้งจากผู้บังคับบัญชา",
"", "",
true true
); );
@ -934,9 +964,9 @@ namespace BMA.EHR.Retirement.Service.Controllers
updated.LastUpdateUserId = UserId ?? ""; updated.LastUpdateUserId = UserId ?? "";
updated.LastUpdatedAt = DateTime.Now; updated.LastUpdatedAt = DateTime.Now;
await _repositoryNoti.PushNotificationAsync( await _repositoryNoti.PushNotificationAsync(
Guid.Parse("aec26ac3-417c-4cf9-9cbe-874939f99ecc"), Guid.Parse("08dc3db9-257d-470d-8256-3dc24f6fa332"),
$"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ได้รับการอนุมัติจากผู้มีอำนาจ", $"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ได้รับการอนุมัติจากผู้มีอำนาจ",
$"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ได้รับการอนุมัติจากผู้มีอำนาจ", $"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ได้รับการอนุมัติจากผู้มีอำนาจ",
"", "",
true true
); );
@ -944,8 +974,8 @@ namespace BMA.EHR.Retirement.Service.Controllers
{ {
await _repositoryNoti.PushNotificationAsync( await _repositoryNoti.PushNotificationAsync(
Guid.Parse(updated.profileId), Guid.Parse(updated.profileId),
$"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ได้รับการอนุมัติจากผู้มีอำนาจ", $"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ได้รับการอนุมัติจากผู้มีอำนาจ",
$"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ได้รับการอนุมัติจากผู้มีอำนาจ", $"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ได้รับการอนุมัติจากผู้มีอำนาจ",
"", "",
true true
); );
@ -981,9 +1011,9 @@ namespace BMA.EHR.Retirement.Service.Controllers
updated.LastUpdateUserId = UserId ?? ""; updated.LastUpdateUserId = UserId ?? "";
updated.LastUpdatedAt = DateTime.Now; updated.LastUpdatedAt = DateTime.Now;
await _repositoryNoti.PushNotificationAsync( await _repositoryNoti.PushNotificationAsync(
Guid.Parse("aec26ac3-417c-4cf9-9cbe-874939f99ecc"), Guid.Parse("08dc3db9-257d-470d-8256-3dc24f6fa332"),
$"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ได้รับการอนุมัติจากผู้มีอำนาจ", $"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ได้รับการอนุมัติจากผู้มีอำนาจ",
$"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ได้รับการอนุมัติจากผู้มีอำนาจ", $"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ได้รับการอนุมัติจากผู้มีอำนาจ",
"", "",
true true
); );
@ -991,8 +1021,8 @@ namespace BMA.EHR.Retirement.Service.Controllers
{ {
await _repositoryNoti.PushNotificationAsync( await _repositoryNoti.PushNotificationAsync(
Guid.Parse(updated.profileId), Guid.Parse(updated.profileId),
$"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ถูกยับยั้งจากผู้มีอำนาจ", $"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ถูกยับยั้งจากผู้มีอำนาจ",
$"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ถูกยับยั้งจากผู้มีอำนาจ", $"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ถูกยับยั้งจากผู้มีอำนาจ",
"", "",
true true
); );