示例#1
0
        public void Add(ChatCountModel chatCountModel)
        {
            var bsonDocumentRequestChatCount = new BsonDocument(
                new Dictionary <string, string> {
                { "IdUsuario", chatCountModel.UserId },
                { "Count", chatCountModel.Count }
            }
                );

            var collectionChatCount = _mongoHelper.MongoDatabase.GetCollection <BsonDocument>("ChatCount");

            collectionChatCount.InsertOne(bsonDocumentRequestChatCount);
        }
示例#2
0
        public void AddMessage(ChatModel chatModel)
        {
            // Grava a mensagem
            _chatRepository.AddMessage(chatModel);

            // Grava a quantidade de mensagens por usuário
            var countByUser = _chatCountRepository.GetByUser(chatModel.UserId);

            var count = 1;

            if (countByUser != null)
            {
                count = Convert.ToInt32(countByUser.GetValue("Count")) + 1;
                _chatCountRepository.DeleteByUser(chatModel.UserId);
            }

            ChatCountModel chatCountModel = new ChatCountModel(chatModel.UserId, count.ToString());

            _chatCountRepository.Add(chatCountModel);
        }