Example #1
0
        public IActionResult AddComment(int postid, [Bind("Content")] NewCommentFormModel newPostFormModel)
        {
            if (newPostFormModel.Content.Trim() == "" ||
                newPostFormModel.Content.Length > 20000)
            {
                return(Redirect("/"));
            }

            var post = postFindService.FindPostById(postid);

            if (post == null)
            {
                return(Redirect("/"));
            }

            newCommentService.AddCommentToPost(postid, newPostFormModel);
            return(Redirect($"/show/{postid}"));
        }
        public IActionResult AddComment(int postid, [Bind("Content")] NewCommentFormModel newPostFormModel)
        {
            if (string.IsNullOrWhiteSpace(newPostFormModel.Content) ||
                Uri.EscapeDataString(newPostFormModel.Content).Contains("%C2%AD") ||
                newPostFormModel.Content.Length > 20000)
            {
                return(RedirectToAction("Index"));
            }

            var post = postFindService.FindPostById(postid);

            if (post == null)
            {
                return(RedirectToAction("Index"));
            }

            newPostFormModel.Country = Request.Headers["CF-IPCountry"].ToString();
            newCommentService.AddCommentToPost(postid, newPostFormModel);
            return(RedirectToAction("Show", new { id = postid }));
        }