本文整理汇总了C#中ICommentService.GetCommentsByParentId方法的典型用法代码示例。如果您正苦于以下问题:C# ICommentService.GetCommentsByParentId方法的具体用法?C# ICommentService.GetCommentsByParentId怎么用?C# ICommentService.GetCommentsByParentId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICommentService
的用法示例。
在下文中一共展示了ICommentService.GetCommentsByParentId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BulidComment
/// <summary>
/// 生成单个评论
/// </summary>
private static string BulidComment(ICommentService commentService, HtmlHelper Html, UrlHelper Url, Comment comment)
{
TagBuilder commentTag = new TagBuilder("li");
commentTag.Attributes.Add("class", "comment byuser comment-author-admin bypostauthor odd alt depth-3");
commentTag.Attributes.Add("id", "comment-" + comment.CommentId);
TagBuilder div = new TagBuilder("div");
div.Attributes.Add("id", "div-comment-" + comment.CommentId);
div.AddCssClass("comment-body");
TagBuilder authorDiv = new TagBuilder("div");
authorDiv.Attributes.Add("class", "comment-author vcard");
TagBuilder img = new TagBuilder("img");
img.Attributes.Add("src", Picture(Html, Url, comment.User));
img.Attributes.Add("class", "avatar avatar-32 photo");
img.Attributes.Add("height", "32");
img.Attributes.Add("width", "32");
TagBuilder cite = new TagBuilder("cite");
cite.AddCssClass("fn");
cite.InnerHtml = comment.User == null ? comment.Author : comment.User.NiceName;
TagBuilder span = new TagBuilder("span");
span.AddCssClass("says");
span.InnerHtml = " 说道:";
if (comment.Status == CommentStatus.Verify)
{
span.InnerHtml += " (等待审核中)";
}
authorDiv.InnerHtml = img.ToString() + cite.ToString() + span.ToString();
TagBuilder metaDiv = new TagBuilder("div");
metaDiv.AddCssClass("comment-meta commentmetadata");
metaDiv.InnerHtml = new TagBuilder("a") { InnerHtml = comment.CreateDate.ToString("yyyy 年 M 月 d 日 " + (comment.CreateDate.Hour <= 12 ? "上午" : "下午") + " h:m") }.ToString();
if (DependencyResolver.Current.GetService<IRoleService>().AdminPower())
{
metaDiv.InnerHtml += "<a class=\"comment-edit-link\" href=\"" + Url.Action("Edit", "Comment", new { area = "Admin", id = comment.CommentId }) + "\" title=\"编辑评论\">(编辑)</a>";
}
TagBuilder content = new TagBuilder("p") { InnerHtml = Encode(Html, comment.Content) };
div.InnerHtml = authorDiv.ToString() + metaDiv.ToString() + content.ToString();
if (comment.Status == CommentStatus.Open)
{
TagBuilder replyDiv = new TagBuilder("div");
replyDiv.AddCssClass("reply");
TagBuilder replyLink = new TagBuilder("a") { InnerHtml = "回复" };
replyLink.AddCssClass("comment-reply-link");
replyLink.Attributes.Add("src", "reComment=" + comment.CommentId + "#respond");
replyLink.Attributes.Add("onclick", "return addComment.moveForm('div-comment-" + comment.CommentId + "', '" + comment.CommentId + "', 'respond', '" + comment.Article.ArticleId + "')");
replyDiv.InnerHtml = replyLink.ToString();
div.InnerHtml += replyDiv.ToString();
}
commentTag.InnerHtml = div.ToString();
IList<Comment> childrenComment = commentService.GetCommentsByParentId(comment.CommentId);
if (childrenComment.Count > 0)
{
commentTag.InnerHtml += (BulidChildren(commentService, Html, Url, childrenComment));
}
return commentTag.ToString();
}