Exemplo n.º 1
0
        public virtual void UpdateVote(Vote vote)
        {
            Boolean foundVote = false;

            Votes.ForEach(cVote =>
            {
                if (cVote.UserId == vote.UserId)
                {
                    cVote     = vote;
                    foundVote = true;
                }
            });
            if (!foundVote)
            {
                Votes.Add(vote);
            }
        }
Exemplo n.º 2
0
        public Dictionary <Answer, int> CountVotes()
        {
            var dict = new Dictionary <Answer, int>();

            Options.ForEach(option =>
            {
                int count = 0;
                Votes.ForEach(vote =>
                {
                    if (vote.Choises.Any(n => n == option.AnswerId))
                    {
                        count++;
                    }
                });
                dict.Add(option, count);
            });

            return(dict);
        }