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.

RemoveUserFromGroupHandler.cs 983B

123456789101112131415161718192021222324252627282930313233
  1. using Diligent.WebAPI.Business.Services;
  2. using Diligent.WebAPI.Host.Mediator.Rooms.Commands;
  3. using MediatR;
  4. namespace Diligent.WebAPI.Host.Mediator.Chat.Handlers
  5. {
  6. public class RemoveUserFromGroupHandler : IRequestHandler<RemoveUserFromGroupCommand, Unit>
  7. {
  8. private readonly RoomService _roomService;
  9. public RemoveUserFromGroupHandler(RoomService roomService)
  10. {
  11. _roomService = roomService;
  12. }
  13. public async Task<Unit> Handle(RemoveUserFromGroupCommand request, CancellationToken cancellationToken)
  14. {
  15. if (request == null)
  16. {
  17. throw new BadHttpRequestException("Object cannot be null");
  18. }
  19. var result = await _roomService.LeaveChatRoom(request.RoomId, request.UserId);
  20. if (!result)
  21. {
  22. throw new Exception("Problem with deleting user from group");
  23. }
  24. return new Unit();
  25. }
  26. }
  27. }