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