Beispiel #1
0
        public ActionResult View(int id, string question, CommentForm comment)
        {
            ICaptchaService captchaService = new ReCaptchaService();
            comment.PassesCaptchaValidation = captchaService.PassesCaptcha(Request, BlogValues.CaptchaPrivateKey());

            int replyId = Int32.TryParse(Request.QueryString["replyId"], out replyId) ? replyId : -1;
            bool replyWithQuote = Boolean.TryParse(Request.QueryString["replyWithQuote"], out replyWithQuote) ? replyWithQuote : false;

            comment.ContainerId = id;
            comment.IpAddress = Request.UserHostAddress;
            comment.ParentCommentId = replyId != -1 ? (int?)replyId : null;

            int commentId = -1;

            if (comment.IsValid(new ModelStateWrapper(ModelState)))
            {
                commentId = PollService.CreatePollComment(comment);
                Response.Redirect("/Poll/" + id + "/" + question + "?fadeComment=" + commentId + "#comments");
            }

            PollDetailView pollDetail = PollService.GetPoll(id, -1, false, -1);
            pollDetail.CommentForm = comment;

            return View("View", pollDetail);
        }
Beispiel #2
0
        public ActionResult View(int id, string blogTitle, CommentForm comment)
        {
            ICaptchaService captchaService = new ReCaptchaService();
            comment.PassesCaptchaValidation = captchaService.PassesCaptcha(Request, BlogValues.CaptchaPrivateKey());

            int replyId = Int32.TryParse(Request.QueryString["replyId"], out replyId) ? replyId : -1;
            bool replyWithQuote = Boolean.TryParse(Request.QueryString["replyWithQuote"], out replyWithQuote) ? replyWithQuote : false;
            int pageNumber = Int32.TryParse(Request.QueryString["page"], out pageNumber) ? pageNumber : 1;

            if (comment.IsValid(new ModelStateWrapper(this.ModelState)))
            {
                BlogService.CreateBlogComment(id, replyId != -1 ? (int?)replyId : null, comment);
                Response.Redirect("/Blog/" + id + "/" + blogTitle + "?awaitingApproval=true#postcomment");
            }

            BlogPageView blogPageView = BlogService.GetBlogPage(id, pageNumber, replyId, replyWithQuote, false);
            blogPageView.CommentForm = comment;

            return View("View", blogPageView);
        }