public async Task <GetCreateMessageChatView> CreateMessage(string messageText, Guid roomId, string userId) { User user = await _userManager.FindByIdAsync(userId); if (user == null) { throw new Exception("User is not find"); } Message message = new Message { Text = messageText, UserId = userId }; MessageInRoom messageInRoom = new MessageInRoom { RoomId = roomId, MessageId = message.Id }; GetCreateMessageChatView response = new GetCreateMessageChatView() { Id = message.Id, CreationAt = _dateTimeHelper.FormatDateFromDb(message.CreationAt), Text = message.Text, FullName = $"{user.FirstName} {user.LastName}", UserId = userId }; await _messageRepository.Create(message); await _messageInRoomRepository.Create(messageInRoom); return(response); }