From 33526755acf3c6a830b1c59d2a4093132c4f93a5 Mon Sep 17 00:00:00 2001 From: Kittapath Date: Thu, 18 Jan 2024 13:53:15 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=80=E0=B8=9E=E0=B8=B4=E0=B9=88=E0=B8=A1?= =?UTF-8?q?=E0=B8=9A=E0=B8=B1=E0=B8=99=E0=B8=97=E0=B8=B6=E0=B8=81=E0=B9=80?= =?UTF-8?q?=E0=B8=A7=E0=B8=A5=E0=B8=B2=E0=B8=AD=E0=B9=88=E0=B8=B2=E0=B8=99?= =?UTF-8?q?noti?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MessageQueue/NotificationRepository.cs | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/BMA.EHR.Application/Repositories/MessageQueue/NotificationRepository.cs b/BMA.EHR.Application/Repositories/MessageQueue/NotificationRepository.cs index 73f292af..cfa855f1 100644 --- a/BMA.EHR.Application/Repositories/MessageQueue/NotificationRepository.cs +++ b/BMA.EHR.Application/Repositories/MessageQueue/NotificationRepository.cs @@ -54,17 +54,6 @@ namespace BMA.EHR.Application.Repositories.MessageQueue .Where(x => x.ReceiverUserId == profile.Id) .Where(x => x.DeleteDate == null) .OrderByDescending(x => x.ReceiveDate) - .Select(x => new NotificationResponse - { - Id = x.Id, - Body = x.Body, - ReceiverUserId = x.ReceiverUserId, - IsOpen = x.IsOpen, - Type = x.Type, - ReceiveDate = x.ReceiveDate, - OpenDate = x.OpenDate, - Payload = x.Payload == "" ? null : JsonConvert.DeserializeObject(Regex.Unescape(x.Payload)) - }) .ToListAsync(); var data = data_search @@ -76,10 +65,23 @@ namespace BMA.EHR.Application.Repositories.MessageQueue foreach (var data_open in data_opens) { data_open.IsOpen = true; + data_open.OpenDate = DateTime.Now; } await _dbContext.SaveChangesAsync(); - var _data = new { data, total = data_search.Count(), totalNoti = data_search.Where(x => x.IsOpen == false).Count() }; + var data2 = data.Select(x => new NotificationResponse + { + Id = x.Id, + Body = x.Body, + ReceiverUserId = x.ReceiverUserId, + IsOpen = x.IsOpen, + Type = x.Type, + ReceiveDate = x.ReceiveDate, + OpenDate = x.OpenDate, + Payload = x.Payload == "" ? null : JsonConvert.DeserializeObject(Regex.Unescape(x.Payload)) + }).ToList(); + + var _data = new { data = data2, total = data_search.Count(), totalNoti = data_search.Where(x => x.IsOpen == false).Count() }; return _data; } catch