Skip to content

Commit

Permalink
[Notification][Hai] order list descending
Browse files Browse the repository at this point in the history
  • Loading branch information
HaiHungNguyenn committed Mar 20, 2024
1 parent 1a44ad2 commit fdc3699
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Domus.Domain/Dtos/DtoNotification.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ public class DtoNotification
public DateTime SentAt { get; set; }
public NotificationStatus Status { get; set; }
public string? RedirectString { get; set; }
public string Image { get; set; }
public string? Image { get; set; }
}
2 changes: 1 addition & 1 deletion Domus.Domain/Entities/Notification.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ public class Notification : BaseEntity<Guid>
public NotificationStatus Status { get; set; }
public string? RedirectString { get; set; }

public string Image { get; set; }
public string? Image { get; set; }
public DomusUser Recipient { get; set; }
}
4 changes: 3 additions & 1 deletion Domus.Service/Implementations/NotificationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,10 @@ public async Task<ServiceActionResult> GetPaginatedNotifications(BasePaginatedRe
if (!isValidToken)
throw new InvalidTokenException();
var userId = _jwtService.GetTokenClaim(token, TokenClaimConstants.SUBJECT)?.ToString() ?? throw new UserNotFoundException();
var notifications = await (await _notificationRepository.FindAsync(x => x.RecipientId.Equals(userId)))
var notifications = await (await _notificationRepository
.FindAsync(x => x.RecipientId.Equals(userId)))
.ProjectTo<DtoNotification>(_mapper.ConfigurationProvider)
.OrderByDescending(x => x.SentAt)
.ToListAsync();
var paginatedList = PaginationHelper.BuildPaginatedResult(notifications.AsQueryable(), request.PageSize, request.PageIndex);
return new ServiceActionResult()
Expand Down

0 comments on commit fdc3699

Please sign in to comment.