using AutoMapper; using Diligent.WebAPI.Business.Services; using Diligent.WebAPI.Host.DTOs.Notification; using Diligent.WebAPI.Host.Mediator.Notifications.Queries; using MediatR; namespace Diligent.WebAPI.Host.Mediator.Notifications.Handlers { public class GetNotificationsHandler : IRequestHandler> { private readonly ICustomerService _customerService; private readonly IMapper _mapper; public GetNotificationsHandler(ICustomerService customerService, IMapper mapper) { _customerService = customerService; _mapper = mapper; } public async Task> Handle(GetNotificationsQuery request, CancellationToken cancellationToken) { if (request == null) { throw new BadHttpRequestException("User id cannot be null"); } return _mapper.Map>(await _customerService.ReadNotifications(request.UserId)); } } }