public Task <List <NotificationDto> > Handle(GetNotificationsByUserIdQuery request, CancellationToken cancellationToken)
 {
     try
     {
         var notifications = _dbContext.Notifications
                             .OrderBy(x => x.Created)
                             .ProjectTo <NotificationDto>(_mapper.ConfigurationProvider)
                             .ToList();
         return(Task.FromResult(notifications));
     }
     catch (Exception ex)
     {
         throw new Exception("There was an error getting the notifications for a user", ex);
     }
 }
Exemplo n.º 2
0
        public async Task <IActionResult> GetNotificationsByUserId([FromQuery] GetNotificationsByUserIdQuery query)
        {
            var result = await Mediator.Send(query);

            return(Ok(result));
        }