Example #1
0
        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
            }));
        }
Example #2
0
        public async Task <IActionResult> NewChat(CreateNewChatCommand command)
        {
            var newChat = await _commandBus.ExecuteAsync <NewChatDTO>(command);

            return(Ok(newChat));
        }