public async Task <ICommandResult <NewChatDTO> > HandleAsync(CreateNewChatCommand command) { Chat chat = new Chat() { FirstParticipantId = command.FirstParticipantId, SecondParticipantId = command.SecondParticipantId }; await _context.Chat.AddAsync(chat); await _context.SaveChangesAsync(); return(CommandResult <NewChatDTO> .Success(new NewChatDTO() { Id = chat.Id })); }
public async Task <IActionResult> NewChat(CreateNewChatCommand command) { var newChat = await _commandBus.ExecuteAsync <NewChatDTO>(command); return(Ok(newChat)); }