Example #1
0
        public ActionResult Submit(BlogCommentInputModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View("Index", CurrentItem));
            }

            BlogComment comment = Engine.Definitions.CreateInstance <BlogComment>(CurrentPage);

            comment.CommentID  = ((BlogPost)CurrentPage).GetNextCommentID();
            comment.Title      = Server.HtmlEncode(model.Title);
            comment.AuthorName = Server.HtmlEncode(model.Name);
            comment.Email      = Server.HtmlEncode(model.Email);
            comment.AuthorUrl  = Server.HtmlEncode(model.Url);
            comment.Text       = model.Text.ToSafeHtml();

            Engine.Persister.Save(comment);

            return(Redirect(CurrentPage.Url + "#c" + comment.CommentID));
        }
Example #2
0
        public IActionResult Add(int id, BlogCommentInputModel model)
        {
            if (!this.ModelState.IsValid)
            {
                var routeValue = new
                {
                    Id = id
                };

                return(this.RedirectToAction(GlobalConstants.DetailsActionName, GlobalConstants.PostsControllerName, routeValue));
            }

            this.blogCommentsService.AddComment(model.Content, id, this.User.Identity.Name);

            var routeValues = new
            {
                Id = id
            };

            return(this.RedirectToAction(GlobalConstants.DetailsActionName, GlobalConstants.PostsControllerName, routeValues));
        }