Beispiel #1
0
        public virtual bool Promote(DateTime at, IUser byUser, string fromIPAddress)
        {
            Check.Argument.IsNotInFuture(at, "at");
            Check.Argument.IsNotNull(byUser, "byUser");
            Check.Argument.IsNotEmpty(fromIPAddress, "fromIPAddress");

            if (CanPromote(byUser))
            {
                StoryVote vote = new StoryVote
                {
                    Story     = this,
                    User      = (User)byUser,
                    IPAddress = fromIPAddress,
                    Timestamp = at
                };

                StoryVotes.Add(vote);
                IoC.Resolve <IVoteRepository>().Add(vote);

                LastActivityAt = at;

                return(true);
            }

            return(false);
        }
Beispiel #2
0
        public virtual bool Demote(DateTime at, IUser byUser)
        {
            Check.Argument.IsNotInvalidDate(at, "at");
            Check.Argument.IsNotNull(byUser, "byUser");

            if (CanDemote(byUser))
            {
                IVoteRepository repository = IoC.Resolve <IVoteRepository>();
                StoryVote       vote       = (StoryVote)repository.FindById(Id, byUser.Id);

                repository.Remove(vote);
                StoryVotes.Remove(vote);

                LastActivityAt = at;

                return(true);
            }

            return(false);
        }