public async Task <List <NotificationResponse> > QueryNotificationAsync(QueryNotificationCommand queryNotificationCommand, CancellationToken cancellationToken) { var notificationRepository = _repositoryFactory.Generate <INotificationRepository>(); IEnumerable <Notification> notifications = await notificationRepository.GetNotificationAsync(queryNotificationCommand.Username, queryNotificationCommand.IsSeen, queryNotificationCommand.Skip, queryNotificationCommand.Take, cancellationToken); List <NotificationResponse> notificationResponses = notifications.Select(x => new NotificationResponse(x.CorrelationId.ToString(), x.Title.ToString(), x.Content.ToString(), x.IsSeen, x.OperationDate)) .ToList(); return(notificationResponses); }
public async Task <IActionResult> GetNotifications([FromRoute] string username, [FromQuery] GetNotificationCollectionHttpRequest?getNotificationCollectionHttpRequest) { CheckTokenIsValid(username); getNotificationCollectionHttpRequest ??= new GetNotificationCollectionHttpRequest(); Username uName = new Username(username); QueryNotificationCommand queryNotificationCommand = new QueryNotificationCommand(uName, getNotificationCollectionHttpRequest.IsSeen, getNotificationCollectionHttpRequest.Skip, getNotificationCollectionHttpRequest.Take); List <NotificationResponse> notificationResponseList = await _notificationService.QueryNotificationAsync(queryNotificationCommand, CancellationToken.None); return(StatusCode((int)HttpStatusCode.OK, notificationResponseList)); }