public
Created

  • Download Gist
Comment.cs
C#
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
[ValidateInput(false)]
[HttpPost]
public ActionResult Comment(CommentInput input, int id, Guid key)
{
var post = RavenSession
.Include<Post>(x => x.CommentsId)
.Load(id);
 
if (post == null || post.IsPublicPost(key) == false)
return HttpNotFound();
 
var comments = RavenSession.Load<PostComments>(post.CommentsId);
if (comments == null)
return HttpNotFound();
 
var commenter = RavenSession.GetCommenter(input.CommenterKey);
if (commenter == null)
{
input.CommenterKey = Guid.NewGuid();
}
 
ValidateCommentsAllowed(post, comments);
ValidateCaptcha(input, commenter);
 
if (ModelState.IsValid == false)
return PostingCommentFailed(post, input, key);
 
TaskExecutor.ExcuteLater(new AddCommentTask(input, Request.MapTo<AddCommentTask.RequestValues>(), id));
 
CommenterUtil.SetCommenterCookie(Response, input.CommenterKey.MapTo<string>());
 
return PostingCommentSucceeded(post, input);
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.