Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

CreateRoomHandler.cs 849B

12345678910111213141516171819202122232425262728
  1. using Diligent.WebAPI.Business.Interfaces;
  2. using Diligent.WebAPI.Business.Services;
  3. using Diligent.WebAPI.Host.Mediator.Rooms.Commands;
  4. using MediatR;
  5. namespace Diligent.WebAPI.Host.Mediator.Chat.Handlers
  6. {
  7. public class CreateRoomHandler : IRequestHandler<CreateRoomCommand, Unit>
  8. {
  9. private readonly IRoomRepository _roomRepository;
  10. public CreateRoomHandler(IRoomRepository roomRepository)
  11. {
  12. _roomRepository = roomRepository;
  13. }
  14. public async Task<Unit> Handle(CreateRoomCommand request, CancellationToken cancellationToken)
  15. {
  16. if (request.Room == null)
  17. {
  18. throw new BadHttpRequestException("Room can't be null");
  19. }
  20. await _roomRepository.CreateAsync(request.Room);
  21. return new Unit();
  22. }
  23. }
  24. }