public JsonResult ChangeSpamMark(int id)
{
Comment comment = CommentServices.FindEntityByIdentity(id);
//Create a new instance of the Akismet API and verify your key is valid.
Akismet api = new Akismet(BgResources.Akismet_API_key, Request.Url.AbsoluteUri, HttpContext.Request.UserAgent);
if (!api.VerifyKey())
{
return Json(new { result = "error", text = Resources.AppMessages.AkismetApikeyInvalid });
}
//Now create an instance of AkismetComment, populating it with values
//from the POSTed form collection.
AkismetComment akismetComment = new AkismetComment
{
Blog = Request.Url.Scheme + "://" + Request.Url.Host,
UserIp = comment.Ip,
UserAgent = comment.UserAgent,
CommentContent = comment.Message,
CommentType = "comment",
CommentAuthor = comment.AnonymousUser != null ? comment.AnonymousUser.Username : comment.User.Username,
CommentAuthorEmail = comment.AnonymousUser != null ? comment.AnonymousUser.Email : comment.User.Email,
CommentAuthorUrl = comment.AnonymousUser != null ? comment.AnonymousUser.Web : String.Empty
};
if (comment.IsSpam)
{
comment.IsSpam = false;
api.SubmitHam(akismetComment);
}
else
{
comment.IsSpam = true;
api.SubmitSpam(akismetComment);
}
BlogServices.SaveComment(comment);
return Json(new { result = "ok" });
}