Exemplo n.º 1
0
        private void SendNewCommentEmail(Post post, PostComments.Comment comment)
        {
            var viewModel = comment.MapTo <NewCommentEmailViewModel>();

            viewModel.PostId    = RavenIdResolver.Resolve(post.Id);
            viewModel.PostTitle = post.Title;
            viewModel.BlogName  = Session.Load <BlogConfig>("Blog/Config").Title;

            var subject = string.Format("Comment on: {0} from {1}", viewModel.PostTitle, viewModel.BlogName);

            if (comment.IsSpam)
            {
                subject = "Spam " + subject;
            }

            CommandExecutor.ExcuteLater(new SendEmailCommand(viewModel.Email, subject, "NewComment", viewModel));
        }
Exemplo n.º 2
0
        public ActionResult Comment(CommentInput input, int id)
        {
            var post = Session
                       .Include <Post>(x => x.CommentsId)
                       .Load(id);

            if (post == null || post.IsPublicPost(Request.QueryString["key"]) == false)
            {
                return(HttpNotFound());
            }

            var comments = Session.Load <PostComments>(post.CommentsId);

            if (comments == null)
            {
                return(HttpNotFound());
            }

            var commenter = GetCommenter(input.CommenterKey) ?? new Commenter {
                Key = Guid.NewGuid()
            };

            ValidateCommentsAllowed(post, comments);
            ValidateCaptcha(input, commenter);

            if (ModelState.IsValid == false)
            {
                return(PostingCommentFailed(post, input));
            }

            CommandExecutor.ExcuteLater(new AddCommentCommand(input, Request.MapTo <RequestValues>(), id));

            SetCommenterCookie(commenter);

            return(PostingCommentSucceeded(post));
        }