コード例 #1
0
ファイル: VoteCounter.cs プロジェクト: MizMahem/NetTally
        /// <summary>
        /// Add a collection of votes to the vote counter.
        /// </summary>
        /// <param name="votePartitions">A string list of all the parts of the vote to be added.</param>
        /// <param name="voter">The voter for this vote.</param>
        /// <param name="postID">The post ID for this vote.</param>
        /// <param name="voteType">The type of vote being added.</param>
        public void AddVotes(IEnumerable <VoteLineBlock> votePartitions, Origin voter)
        {
            if (!votePartitions.Any())
            {
                return;
            }

            // Remove the voter from any existing votes
            VoteStorage.RemoveVoterFromVotes(voter);

            // Add/update all segments of the provided vote
            foreach (var partition in votePartitions)
            {
                VoteStorage.AddSupporterToVote(partition, voter);
                AddPotentialVoteTask(partition.Task);
            }

            // Cleanup any votes that no longer have any support
            VoteStorage.RemoveUnsupportedVotes();
        }