Ejemplo n.º 1
0
        public virtual bool MarkAsSpam(DateTime at, IUser byUser, string fromIPAddress)
        {
            Check.Argument.IsNotInFuture(at, "at");
            Check.Argument.IsNotNull(byUser, "byUser");
            Check.Argument.IsNotEmpty(fromIPAddress, "fromIPAddress");

            if (CanMarkAsSpam(byUser))
            {
                StoryMarkAsSpam markAsSpam = new StoryMarkAsSpam
                {
                    Story     = this,
                    User      = (User)byUser,
                    IPAddress = fromIPAddress,
                    Timestamp = at
                };

                StoryMarkAsSpams.Add(markAsSpam);
                IoC.Resolve <IMarkAsSpamRepository>().Add(markAsSpam);

                LastActivityAt = at;

                return(true);
            }

            return(false);
        }
Ejemplo n.º 2
0
        public virtual bool UnmarkAsSpam(DateTime at, IUser byUser)
        {
            Check.Argument.IsNotInvalidDate(at, "at");
            Check.Argument.IsNotNull(byUser, "byUser");

            if (CanUnmarkAsSpam(byUser))
            {
                IMarkAsSpamRepository repository = IoC.Resolve <IMarkAsSpamRepository>();

                StoryMarkAsSpam spam = (StoryMarkAsSpam)repository.FindById(Id, byUser.Id);
                repository.Remove(spam);
                StoryMarkAsSpams.Remove(spam);

                LastActivityAt = at;

                return(true);
            }

            return(false);
        }