Esempio n. 1
0
        public virtual void Vote(VoteType type, User user)
        {
            if (type == VoteType.Down)
            {
                throw new NotSupportedException();
            }
            if (Status != Public)
            {
                throw new NotFoundException();
            }



            var vote = Votes.AsQueryable().FirstOrDefault(w => w.User == user);

            if (vote == null)
            {
                vote = new Vote(user, this, type);
                _votes.Add(vote);
            }
            vote.VoteType = type;
            VoteCount     = Votes.Sum(s => (int)s.VoteType);
        }