Beispiel #1
0
        public async Task <ChatConversation> SendMessageToChat(string appId, string chatId, string userId, string message)
        {
            var user = await _userRepository.GetAsync(appId, userId);

            var chat = await _chatRepository.GetAsync(appId, chatId);

            if (chat != null)
            {
                var chatConversation = new ChatConversation()
                {
                    Id     = ObjectId.GenerateNewId().ToString(),
                    UserId = user.Id,
                    Date   = DateTime.Now,
                    Text   = message,
                    ChatConversationReaders = new List <ChatConversationReader> (),
                    User = new User()
                    {
                        Id       = user.Id,
                        FullName = user.FullName
                    }
                };

                await _chatRepository.AddMessageToChatAsync(chatId, chatConversation);

                return(chatConversation);
            }
            return(null);
        }