Example #1
0
        public bool AddVote(User user, VoteType type)
        {
            var foundVote = Votes.Find(v => v.UserId == user.Id);

            if (foundVote != null)
            {
                if (foundVote.Type != type)
                {
                    Votes.Remove(foundVote);
                }
                else
                {
                    return(false);
                }
            }
            Votes.Add(new Vote(user, type));
            return(true);
        }