Created
September 20, 2012 13:31
-
-
Save jbogard/3755938 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment