Merge branch 'develop' into working

This commit is contained in:
Suphonchai Phoonsawat 2024-01-18 05:50:56 +07:00
commit ce746e4034
3 changed files with 20 additions and 12 deletions

View file

@ -33,7 +33,7 @@ namespace BMA.EHR.Application.Repositories.MessageQueue
#region " Methods " #region " Methods "
public async Task<List<InboxResponse>> GetMyInboxAsync() public async Task<dynamic> GetMyInboxAsync(int page = 1, int pageSize = 25)
{ {
try try
{ {
@ -46,7 +46,7 @@ namespace BMA.EHR.Application.Repositories.MessageQueue
// throw new Exception(GlobalMessages.DataNotFound); // throw new Exception(GlobalMessages.DataNotFound);
} }
var data = await _dbContext.Set<Inbox>() var data_search = await _dbContext.Set<Inbox>()
.Where(x => x.ReceiverUserId == profile.Id) .Where(x => x.ReceiverUserId == profile.Id)
.Where(x => x.IsOpen == false) .Where(x => x.IsOpen == false)
.OrderByDescending(x => x.ReceiveDate) .OrderByDescending(x => x.ReceiveDate)
@ -61,10 +61,14 @@ namespace BMA.EHR.Application.Repositories.MessageQueue
OpenDate = x.OpenDate, OpenDate = x.OpenDate,
Payload = x.Payload == "" ? null : JsonConvert.DeserializeObject<CommandPayload>(Regex.Unescape(x.Payload)) Payload = x.Payload == "" ? null : JsonConvert.DeserializeObject<CommandPayload>(Regex.Unescape(x.Payload))
}) })
.Take(20)
.ToListAsync(); .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 catch
{ {

View file

@ -37,7 +37,7 @@ namespace BMA.EHR.Application.Repositories.MessageQueue
#region " Methods " #region " Methods "
public async Task<List<NotificationResponse>> GetMyNotificationAsync() public async Task<dynamic> GetMyNotificationAsync(int page = 1, int pageSize = 25)
{ {
try try
{ {
@ -50,7 +50,7 @@ namespace BMA.EHR.Application.Repositories.MessageQueue
// throw new Exception(GlobalMessages.DataNotFound); // throw new Exception(GlobalMessages.DataNotFound);
} }
var data = await _dbContext.Set<Notification>() var data_search = await _dbContext.Set<Notification>()
.Where(x => x.ReceiverUserId == profile.Id) .Where(x => x.ReceiverUserId == profile.Id)
.Where(x => x.IsOpen == false) .Where(x => x.IsOpen == false)
.OrderByDescending(x => x.ReceiveDate) .OrderByDescending(x => x.ReceiveDate)
@ -65,10 +65,14 @@ namespace BMA.EHR.Application.Repositories.MessageQueue
OpenDate = x.OpenDate, OpenDate = x.OpenDate,
Payload = x.Payload == "" ? null : JsonConvert.DeserializeObject<CommandPayload>(Regex.Unescape(x.Payload)) Payload = x.Payload == "" ? null : JsonConvert.DeserializeObject<CommandPayload>(Regex.Unescape(x.Payload))
}) })
.Take(20)
.ToListAsync(); .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 catch
{ {

View file

@ -45,11 +45,11 @@ namespace BMA.EHR.Command.Service.Controllers
[ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)] [ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<ResponseObject>> GetMyInboxAsync() public async Task<ActionResult<ResponseObject>> GetMyInboxAsync(int page = 1, int pageSize = 20)
{ {
try try
{ {
var inboxes = await _inboxRepository.GetMyInboxAsync(); var inboxes = await _inboxRepository.GetMyInboxAsync(page, pageSize);
return Success(inboxes); return Success(inboxes);
} }
@ -120,11 +120,11 @@ namespace BMA.EHR.Command.Service.Controllers
[ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)] [ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<ResponseObject>> GetMyNotificationAsync() public async Task<ActionResult<ResponseObject>> GetMyNotificationAsync(int page = 1, int pageSize = 20)
{ {
try try
{ {
var noti = await _notificationRepository.GetMyNotificationAsync(); var noti = await _notificationRepository.GetMyNotificationAsync(page, pageSize);
return Success(noti); return Success(noti);
} }