From baf828ac854fcad6c7151326fafc900a7ee67932 Mon Sep 17 00:00:00 2001 From: harid Date: Mon, 22 Jun 2026 13:21:33 +0700 Subject: [PATCH 1/2] fix #2571 --- .../Controllers/RetirementOtherController.cs | 6 +----- BMA.EHR.Retirement.Service/Requests/OrgRequest.cs | 1 + 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/BMA.EHR.Retirement.Service/Controllers/RetirementOtherController.cs b/BMA.EHR.Retirement.Service/Controllers/RetirementOtherController.cs index 4880f3b6..868aac4f 100644 --- a/BMA.EHR.Retirement.Service/Controllers/RetirementOtherController.cs +++ b/BMA.EHR.Retirement.Service/Controllers/RetirementOtherController.cs @@ -449,11 +449,7 @@ namespace BMA.EHR.Retirement.Service.Controllers retirementOther.PositionLevelOld = org.result.posLevelName; retirementOther.PositionTypeOld = org.result.posTypeName; retirementOther.PositionNumberOld = org.result.posNo; - retirementOther.OrganizationOld = (org.result.child4 == null ? "" : org.result.child4 + "\n") + - (org.result.child3 == null ? "" : org.result.child3 + "\n") + - (org.result.child2 == null ? "" : org.result.child2 + "\n") + - (org.result.child1 == null ? "" : org.result.child1 + "\n") + - (org.result.root == null ? "" : org.result.root); + retirementOther.OrganizationOld = org.result.org ?? ""; retirementOther.OrganizationPositionOld = org.result.position + "\n" + (retirementOther.PositionExecutiveOld == null ? "" : (retirementOther.positionExecutiveField == null ? retirementOther.PositionExecutiveOld + "\n" : retirementOther.PositionExecutiveOld + "(" + retirementOther.positionExecutiveField + ")" + "\n")) + retirementOther.OrganizationOld; diff --git a/BMA.EHR.Retirement.Service/Requests/OrgRequest.cs b/BMA.EHR.Retirement.Service/Requests/OrgRequest.cs index d68ed4a1..0dda38be 100644 --- a/BMA.EHR.Retirement.Service/Requests/OrgRequest.cs +++ b/BMA.EHR.Retirement.Service/Requests/OrgRequest.cs @@ -54,5 +54,6 @@ namespace BMA.EHR.Retirement.Service.Requests public DateTime? leaveDate { get; set; } public string? education { get; set; } public double? salary { get; set; } + public string? org { get; set; } } } \ No newline at end of file From f4f56b1c21ee9b608ec75eb87d14fef4ce40844a Mon Sep 17 00:00:00 2001 From: harid Date: Mon, 22 Jun 2026 16:36:06 +0700 Subject: [PATCH 2/2] =?UTF-8?q?api=20=E0=B8=A5=E0=B8=9A=E0=B8=82=E0=B9=89?= =?UTF-8?q?=E0=B8=AD=E0=B8=84=E0=B8=A7=E0=B8=B2=E0=B8=A1=20noti=20#1599?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MessageQueue/NotificationRepository.cs | 38 +++++++++++++++++++ .../Controllers/MessageController.cs | 25 ++++++++++++ 2 files changed, 63 insertions(+) diff --git a/BMA.EHR.Application/Repositories/MessageQueue/NotificationRepository.cs b/BMA.EHR.Application/Repositories/MessageQueue/NotificationRepository.cs index a9d5ceb7..9a8d71e3 100644 --- a/BMA.EHR.Application/Repositories/MessageQueue/NotificationRepository.cs +++ b/BMA.EHR.Application/Repositories/MessageQueue/NotificationRepository.cs @@ -187,6 +187,44 @@ namespace BMA.EHR.Application.Repositories.MessageQueue } } + private async Task GetMyProfileIdAsync() + { + var apiUrl = $"{_configuration["API"]}/org/dotnet/get-profileId"; + var response = await GetExternalAPIAsync(apiUrl, AccessToken!, _configuration["API_KEY"]!); + + if (string.IsNullOrWhiteSpace(response)) + return string.Empty; + + var org = JsonConvert.DeserializeObject(response); + if (org == null || org.result == null) + return string.Empty; + + return org.result.profileId ?? string.Empty; + } + + public async Task DeleteAllMyNotificationsAsync() + { + try + { + var profileId = await GetMyProfileIdAsync(); + if (string.IsNullOrEmpty(profileId)) + return 0; + + var notifications = await _dbContext.Set() + .Where(x => x.ReceiverUserId == Guid.Parse(profileId)) + .Where(x => x.DeleteDate == null) + .ToListAsync(); + + _dbContext.Set().RemoveRange(notifications); + await _dbContext.SaveChangesAsync(); + return notifications.Count; + } + catch + { + throw; + } + } + public async Task PushNotificationAsync(Guid ReceiverUserId, string Subject, string Body, string Payload = "", string NotiLink = "", bool IsSendInbox = false, bool IsSendMail = false) { try diff --git a/BMA.EHR.Placement.Service/Controllers/MessageController.cs b/BMA.EHR.Placement.Service/Controllers/MessageController.cs index c4434eb1..9c8ffdfd 100644 --- a/BMA.EHR.Placement.Service/Controllers/MessageController.cs +++ b/BMA.EHR.Placement.Service/Controllers/MessageController.cs @@ -184,6 +184,31 @@ namespace BMA.EHR.Placement.Service.Controllers } } + /// + /// ลบ Notification ทั้งหมดของ user ที่ login (Hard delete) + /// + /// จำนวนรายการที่ถูกลบ + /// เมื่อทำการลบข้อมูลจาก Relational Database สำเร็จ + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpDelete("my-notifications")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status500InternalServerError)] + public async Task> PermanentDeleteAllMyNotificationsAsync() + { + try + { + var affectedRows = await _notificationRepository.DeleteAllMyNotificationsAsync(); + + return Success(affectedRows); + } + catch + { + throw; + } + } + #endregion }