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.

CreateRoomHandler.cs 787B

123456789101112131415161718192021222324252627
  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 CreateRoomHandler : IRequestHandler<CreateRoomCommand, Unit>
  7. {
  8. private readonly RoomService _roomService;
  9. public CreateRoomHandler(RoomService roomService)
  10. {
  11. _roomService = roomService;
  12. }
  13. public async Task<Unit> Handle(CreateRoomCommand request, CancellationToken cancellationToken)
  14. {
  15. if (request.Room == null)
  16. {
  17. throw new BadHttpRequestException("Room can't be null");
  18. }
  19. await _roomService.CreateRoomAsync(request.Room);
  20. return new Unit();
  21. }
  22. }
  23. }