public async Task <IActionResult> Get(NotificationListRequest model)
        {
            var command  = new GetNotificationListCommand(model);
            var response = await _mediator.Send(command);

            return(Ok(response));
        }
Exemple #2
0
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task <PaginatedResponse <IList <Notification> > > Handle(GetNotificationListCommand command, CancellationToken cancellationToken)
        {
            NotificationListRequest request = command.Request;
            IList <Notification>    list    =
                await _notificationRepository.GetListAsync(request.GetLimit(), request.GetOffset(), x => x.CreatedOn, true);

            long total = await _notificationRepository.GetListTotalAsync(x => x.CreatedOn, true);

            int totalPages = (int)Math.Ceiling((decimal)total / request.EntriesPerPage);
            var result     = new PaginatedResponse <IList <Notification> >(list, total, request.Page, totalPages, request.GetLimit());

            return(result);
        }
 public GetNotificationListCommand(NotificationListRequest model)
 {
     Request = model;
 }