Пример #1
0
        private async Task <int> AddVoteAsync(string userId, string nodeId, bool isUpVote)
        {
            var weight = await GetWeightAsync(userId);

            var score = (short)(isUpVote ? weight : -weight);
            var vote  = new NodeVote()
            {
                Id     = Guid.NewGuid().ToString(),
                NodeId = nodeId,
                UserId = userId,
                Score  = score
            };

            _nodeRepository.AddVote(vote);
            return(await UpdateHotAsync(vote, false));
        }