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.

DeleteNotificationHandler.cs 1.0KB

123456789101112131415161718192021222324252627282930313233
  1. using Diligent.WebAPI.Business.Interfaces;
  2. using Diligent.WebAPI.Host.Mediator.Notifications.Commands;
  3. using MediatR;
  4. namespace Diligent.WebAPI.Host.Mediator.Notifications.Handlers
  5. {
  6. public class DeleteNotificationHandler : IRequestHandler<DeleteNotificationCommand, Unit>
  7. {
  8. private readonly ICustomerService _customerService;
  9. public DeleteNotificationHandler(ICustomerService customerService)
  10. {
  11. _customerService = customerService;
  12. }
  13. public async Task<Unit> Handle(DeleteNotificationCommand request, CancellationToken cancellationToken)
  14. {
  15. if (request == null)
  16. {
  17. throw new BadHttpRequestException("Object cannot be null");
  18. }
  19. var result = await _customerService.DeleteNotification(request.NotificationData.UserId, request.NotificationData.RoomId);
  20. if (!result)
  21. {
  22. throw new Exception("Problem with deleting notification");
  23. }
  24. return new Unit();
  25. }
  26. }
  27. }