public JsonpResult GetPost(int postid)
{
Post post = this.BlogServices.FindPost(postid);
if (post.IsPublic)
{
return this.Jsonp(new
{
title = post.Title,
description = post.Description,
text = post.Text.Replace("../../..", Request.Url.Scheme + "://" + Request.Url.Authority),
commentscount = post.Comments.Count<Comment>(),
date = post.DateCreated.ToShortDateString(),
category = post.Category.Name,
thumbnailpath = getImageUrl(post.Image),
user = post.User.Username,
tags =
from t in post.Tags
select new
{
name = t.TagName,
description = t.TagDescription
},
visits = post.Visits,
ratings =
from r in post.Ratings
select new
{
value = r.Value
},
comments =
from c in post.Comments
where ((c.IsSpam == false) && (c.isRelatedComment == false))
select new
{
id = c.CommentId,
message = c.Message,
user = c.User != null ? c.User.Username : c.AnonymousUser.Username,
isrelated = c.isRelatedComment,
relatedcomments =
from rc in c.RelatedComments
where (rc.IsSpam == false)
select new
{
id = rc.CommentId,
message = rc.Message,
user = rc.User != null ? rc.User.Username : rc.AnonymousUser.Username,
}
}
});
}
else
{
return this.Jsonp(new
{
message = "error"
});
}
}