You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

GetNotificationsHandler.cs 1.0KB

123456789101112131415161718192021222324252627282930
  1. using AutoMapper;
  2. using Diligent.WebAPI.Business.Interfaces;
  3. using Diligent.WebAPI.Host.DTOs.Notification;
  4. using Diligent.WebAPI.Host.Mediator.Notifications.Queries;
  5. using MediatR;
  6. namespace Diligent.WebAPI.Host.Mediator.Notifications.Handlers
  7. {
  8. public class GetNotificationsHandler : IRequestHandler<GetNotificationsQuery, List<NotificationReadDTO>>
  9. {
  10. private readonly ICustomerService _customerService;
  11. private readonly IMapper _mapper;
  12. public GetNotificationsHandler(ICustomerService customerService, IMapper mapper)
  13. {
  14. _customerService = customerService;
  15. _mapper = mapper;
  16. }
  17. public async Task<List<NotificationReadDTO>> Handle(GetNotificationsQuery request, CancellationToken cancellationToken)
  18. {
  19. if (request == null)
  20. {
  21. throw new BadHttpRequestException("User id cannot be null");
  22. }
  23. return _mapper.Map<List<NotificationReadDTO>>(await _customerService.ReadNotifications(request.UserId));
  24. }
  25. }
  26. }