diff --git a/BMA.EHR.Application/Repositories/MessageQueue/InboxRepository.cs b/BMA.EHR.Application/Repositories/MessageQueue/InboxRepository.cs index 1b3d8dc1..c28def82 100644 --- a/BMA.EHR.Application/Repositories/MessageQueue/InboxRepository.cs +++ b/BMA.EHR.Application/Repositories/MessageQueue/InboxRepository.cs @@ -33,7 +33,7 @@ namespace BMA.EHR.Application.Repositories.MessageQueue #region " Methods " - public async Task> GetMyInboxAsync() + public async Task GetMyInboxAsync(int page = 1, int pageSize = 25) { try { @@ -46,7 +46,7 @@ namespace BMA.EHR.Application.Repositories.MessageQueue // throw new Exception(GlobalMessages.DataNotFound); } - var data = await _dbContext.Set() + var data_search = await _dbContext.Set() .Where(x => x.ReceiverUserId == profile.Id) .Where(x => x.IsOpen == false) .OrderByDescending(x => x.ReceiveDate) @@ -61,10 +61,14 @@ namespace BMA.EHR.Application.Repositories.MessageQueue OpenDate = x.OpenDate, Payload = x.Payload == "" ? null : JsonConvert.DeserializeObject(Regex.Unescape(x.Payload)) }) - .Take(20) .ToListAsync(); - return data; + var data = data_search + .Skip((page - 1) * pageSize) + .Take(pageSize) + .ToList(); + var _data = new { data, total = data_search.Count() }; + return _data; } catch { diff --git a/BMA.EHR.Application/Repositories/MessageQueue/NotificationRepository.cs b/BMA.EHR.Application/Repositories/MessageQueue/NotificationRepository.cs index 1d95e591..e0a0fe9d 100644 --- a/BMA.EHR.Application/Repositories/MessageQueue/NotificationRepository.cs +++ b/BMA.EHR.Application/Repositories/MessageQueue/NotificationRepository.cs @@ -37,7 +37,7 @@ namespace BMA.EHR.Application.Repositories.MessageQueue #region " Methods " - public async Task> GetMyNotificationAsync() + public async Task GetMyNotificationAsync(int page = 1, int pageSize = 25) { try { @@ -50,7 +50,7 @@ namespace BMA.EHR.Application.Repositories.MessageQueue // throw new Exception(GlobalMessages.DataNotFound); } - var data = await _dbContext.Set() + var data_search = await _dbContext.Set() .Where(x => x.ReceiverUserId == profile.Id) .Where(x => x.IsOpen == false) .OrderByDescending(x => x.ReceiveDate) @@ -65,10 +65,14 @@ namespace BMA.EHR.Application.Repositories.MessageQueue OpenDate = x.OpenDate, Payload = x.Payload == "" ? null : JsonConvert.DeserializeObject(Regex.Unescape(x.Payload)) }) - .Take(20) .ToListAsync(); - return data; + var data = data_search + .Skip((page - 1) * pageSize) + .Take(pageSize) + .ToList(); + var _data = new { data, total = data_search.Count() }; + return _data; } catch { diff --git a/BMA.EHR.Command.Service/Controllers/MessageController.cs b/BMA.EHR.Command.Service/Controllers/MessageController.cs index 6e33170d..cde70c46 100644 --- a/BMA.EHR.Command.Service/Controllers/MessageController.cs +++ b/BMA.EHR.Command.Service/Controllers/MessageController.cs @@ -45,11 +45,11 @@ namespace BMA.EHR.Command.Service.Controllers [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] - public async Task> GetMyInboxAsync() + public async Task> GetMyInboxAsync(int page = 1, int pageSize = 20) { try { - var inboxes = await _inboxRepository.GetMyInboxAsync(); + var inboxes = await _inboxRepository.GetMyInboxAsync(page, pageSize); return Success(inboxes); } @@ -120,11 +120,11 @@ namespace BMA.EHR.Command.Service.Controllers [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] - public async Task> GetMyNotificationAsync() + public async Task> GetMyNotificationAsync(int page = 1, int pageSize = 20) { try { - var noti = await _notificationRepository.GetMyNotificationAsync(); + var noti = await _notificationRepository.GetMyNotificationAsync(page, pageSize); return Success(noti); }