From 8c540b656854a3bdaf49eaf7862d1e8f580354a5 Mon Sep 17 00:00:00 2001 From: Kittapath Date: Mon, 5 Aug 2024 14:33:30 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89noti?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MessageQueue/InboxRepository.cs | 2 +- .../MessageQueue/NotificationRepository.cs | 50 +++++------ .../Controllers/RetirementResignController.cs | 86 +++++++++++++------ 3 files changed, 84 insertions(+), 54 deletions(-) diff --git a/BMA.EHR.Application/Repositories/MessageQueue/InboxRepository.cs b/BMA.EHR.Application/Repositories/MessageQueue/InboxRepository.cs index 8034f3d5..d8ff485c 100644 --- a/BMA.EHR.Application/Repositories/MessageQueue/InboxRepository.cs +++ b/BMA.EHR.Application/Repositories/MessageQueue/InboxRepository.cs @@ -64,7 +64,7 @@ namespace BMA.EHR.Application.Repositories.MessageQueue if (org == null || org.result == null) return new List(); - profileId = org.result.rootId == null ? "" : org.result.profileId; + profileId = org.result.profileId == null ? "" : org.result.profileId; } if (profileId == null || profileId == "") return new List(); diff --git a/BMA.EHR.Application/Repositories/MessageQueue/NotificationRepository.cs b/BMA.EHR.Application/Repositories/MessageQueue/NotificationRepository.cs index d8cc4775..7aa12290 100644 --- a/BMA.EHR.Application/Repositories/MessageQueue/NotificationRepository.cs +++ b/BMA.EHR.Application/Repositories/MessageQueue/NotificationRepository.cs @@ -68,7 +68,7 @@ namespace BMA.EHR.Application.Repositories.MessageQueue if (org == null || org.result == null) return new List(); - profileId = org.result.rootId == null ? "" : org.result.profileId; + profileId = org.result.profileId == null ? "" : org.result.profileId; } if (profileId == null || profileId == "") return new List(); @@ -143,7 +143,7 @@ namespace BMA.EHR.Application.Repositories.MessageQueue if (org == null || org.result == null) return 0; - profileId = org.result.rootId == null ? "" : org.result.profileId; + profileId = org.result.profileId == null ? "" : org.result.profileId; } if (profileId == null || profileId == "") return 0; @@ -190,11 +190,26 @@ namespace BMA.EHR.Application.Repositories.MessageQueue // var profile = await _dbContext.Set().FirstOrDefaultAsync(x => x.Id == ReceiverUserId); //if (profile != null) //{ - _dbContext.Set().Add(new Notification + _dbContext.Set().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().Add(new Inbox { + Subject = Subject, Body = Body, ReceiverUserId = ReceiverUserId, - Type = "", Payload = Payload, CreatedFullName = FullName ?? "System Administrator", CreatedUserId = UserId ?? "", @@ -203,27 +218,12 @@ namespace BMA.EHR.Application.Repositories.MessageQueue LastUpdateUserId = UserId ?? "", LastUpdatedAt = DateTime.Now, }); - if (IsSendInbox == true) - { - _dbContext.Set().Add(new Inbox - { - Subject = Subject, - Body = Body, - 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(); + } + if (IsSendMail == true) + { + _emailSenderService.SendMail(Subject, Body, "kittapath@frappet.com"); + } + await _dbContext.SaveChangesAsync(); //} } catch diff --git a/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs b/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs index 3e49a796..c2161642 100644 --- a/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs +++ b/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs @@ -492,7 +492,7 @@ namespace BMA.EHR.Retirement.Service.Controllers } } 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} ได้ทำการยื่นขอลาออก", "", @@ -638,9 +638,39 @@ namespace BMA.EHR.Retirement.Service.Controllers } else { - 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.LastUpdateFullName = FullName ?? "System Administrator"; updated.LastUpdateUserId = UserId ?? ""; @@ -752,8 +782,8 @@ namespace BMA.EHR.Retirement.Service.Controllers updated.LastUpdatedAt = DateTime.Now; await _repositoryNoti.PushNotificationAsync( 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 ); @@ -761,8 +791,8 @@ namespace BMA.EHR.Retirement.Service.Controllers { await _repositoryNoti.PushNotificationAsync( 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 ); @@ -799,8 +829,8 @@ namespace BMA.EHR.Retirement.Service.Controllers updated.LastUpdatedAt = DateTime.Now; await _repositoryNoti.PushNotificationAsync( 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 ); @@ -808,8 +838,8 @@ namespace BMA.EHR.Retirement.Service.Controllers { await _repositoryNoti.PushNotificationAsync( 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 ); @@ -844,8 +874,8 @@ namespace BMA.EHR.Retirement.Service.Controllers updated.LastUpdatedAt = DateTime.Now; await _repositoryNoti.PushNotificationAsync( 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 ); @@ -853,8 +883,8 @@ namespace BMA.EHR.Retirement.Service.Controllers { await _repositoryNoti.PushNotificationAsync( 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 ); @@ -891,8 +921,8 @@ namespace BMA.EHR.Retirement.Service.Controllers updated.LastUpdatedAt = DateTime.Now; await _repositoryNoti.PushNotificationAsync( 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 ); @@ -900,8 +930,8 @@ namespace BMA.EHR.Retirement.Service.Controllers { await _repositoryNoti.PushNotificationAsync( 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 ); @@ -934,9 +964,9 @@ namespace BMA.EHR.Retirement.Service.Controllers updated.LastUpdateUserId = UserId ?? ""; updated.LastUpdatedAt = DateTime.Now; await _repositoryNoti.PushNotificationAsync( - Guid.Parse("aec26ac3-417c-4cf9-9cbe-874939f99ecc"), - $"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ได้รับการอนุมัติจากผู้มีอำนาจ", - $"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ได้รับการอนุมัติจากผู้มีอำนาจ", + Guid.Parse("08dc3db9-257d-470d-8256-3dc24f6fa332"), + $"คำขอลาออกของ {updated.prefix}{updated.firstName} {updated.lastName} ได้รับการอนุมัติจากผู้มีอำนาจ", + $"คำขอลาออกของ {updated.prefix}{updated.firstName} {updated.lastName} ได้รับการอนุมัติจากผู้มีอำนาจ", "", true ); @@ -944,8 +974,8 @@ namespace BMA.EHR.Retirement.Service.Controllers { await _repositoryNoti.PushNotificationAsync( 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 ); @@ -981,9 +1011,9 @@ namespace BMA.EHR.Retirement.Service.Controllers updated.LastUpdateUserId = UserId ?? ""; updated.LastUpdatedAt = DateTime.Now; await _repositoryNoti.PushNotificationAsync( - Guid.Parse("aec26ac3-417c-4cf9-9cbe-874939f99ecc"), - $"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ได้รับการอนุมัติจากผู้มีอำนาจ", - $"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ได้รับการอนุมัติจากผู้มีอำนาจ", + Guid.Parse("08dc3db9-257d-470d-8256-3dc24f6fa332"), + $"คำขอลาออกของ {updated.prefix}{updated.firstName} {updated.lastName} ได้รับการอนุมัติจากผู้มีอำนาจ", + $"คำขอลาออกของ {updated.prefix}{updated.firstName} {updated.lastName} ได้รับการอนุมัติจากผู้มีอำนาจ", "", true ); @@ -991,8 +1021,8 @@ namespace BMA.EHR.Retirement.Service.Controllers { await _repositoryNoti.PushNotificationAsync( 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 );