api ลบข้อความ noti #1599
All checks were successful
Build & Deploy Placement Service / build (push) Successful in 2m2s

This commit is contained in:
harid 2026-06-22 16:36:06 +07:00
parent baf828ac85
commit f4f56b1c21
2 changed files with 63 additions and 0 deletions

View file

@ -187,6 +187,44 @@ namespace BMA.EHR.Application.Repositories.MessageQueue
}
}
private async Task<string> 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<OrgRequest>(response);
if (org == null || org.result == null)
return string.Empty;
return org.result.profileId ?? string.Empty;
}
public async Task<int> DeleteAllMyNotificationsAsync()
{
try
{
var profileId = await GetMyProfileIdAsync();
if (string.IsNullOrEmpty(profileId))
return 0;
var notifications = await _dbContext.Set<Notification>()
.Where(x => x.ReceiverUserId == Guid.Parse(profileId))
.Where(x => x.DeleteDate == null)
.ToListAsync();
_dbContext.Set<Notification>().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