Exemplo n.º 1
0
        public virtual ActionResult AddComment(CommentDetails commentDetails)
        {
            if (ModelState.IsValid)
            {
                long t = 0;
                string timeTaken = Request.Form["t"];

                if(timeTaken == null || Int64.TryParse(timeTaken, out t) == false || t < 10000)
                {
                    this.ModelState.AddModelError("validation", "Validation error");
                    return ViewPost(commentDetails.PostId, commentDetails);
                }

                Comment comment = GetComment(commentDetails);

                commentService.AddComment(comment, commentDetails.PostId);

                return Redirect(Url.RouteUrl(comment.Post.GetActionUrl().GetRouteValueDictionary()) + "#comment-"+comment.Id);
            }
            else
                return ViewPost(commentDetails.PostId, commentDetails);
        }
Exemplo n.º 2
0
        private Comment GetComment(CommentDetails commentDetails)
        {
            Comment comment = new Comment { Text = commentDetails.Text };
            User user = new User { Email = commentDetails.UserEmail, Name = commentDetails.UserName, WebSite = commentDetails.UserWebSite };
            comment.User = user;

            return comment;
        }
Exemplo n.º 3
0
        protected virtual ActionResult ViewPost(int id, CommentDetails commentDetails)
        {
            Post p = postServices.GetPostById(id);

            PostDetails details = Mapper.Map<Post, PostDetails>(p);

            details.EditedComment = commentDetails;

            return View(MVC.Posts.Views.ViewPost, details);
        }