private void BindContent() { BehaviorAdvicePageItem item = Sitecore.Context.Item; litCommentsCount.Text = CommunityHelper.GetTotalComments(item.BlogId.Raw, item.BlogPostId.Raw).ToString(); litHelpfulCount.Text = CommunityHelper.GetTotalLikes(item.ContentId.Raw).ToString(); }
public Comment(XmlNode xn) { if (xn != null) { XmlNode author = xn.SelectSingleNode("User"); string commentId = xn["CommentId"].InnerText; string commentDate = xn["CreatedDate"].InnerText; DateTime parsedDate = DateTime.Parse(commentDate); Id = commentId; //Url = xn["Url"].InnerText; // ParentId = xn["ParentId"].InnerText; // ContentId = xn["ContentId"].InnerText; IsApproved = xn["IsApproved"].InnerText; ReplyCount = xn["ReplyCount"].InnerText; CommentId = commentId; CommentContentTypeId = xn["CommentContentTypeId"].InnerText; Body = xn["Body"].InnerText; PublishedDate = UnderstoodDotOrg.Common.Helpers.DataFormatHelper.FormatDate(commentDate); AuthorId = author["Id"].InnerText; AuthorAvatarUrl = author["AvatarUrl"].InnerText; AuthorDisplayName = author["DisplayName"].InnerText; AuthorProfileUrl = author["ProfileUrl"].InnerText; AuthorUsername = author["Username"].InnerText; Likes = CommunityHelper.GetTotalLikes(commentId).ToString(); CommentDate = parsedDate; ParentTitle = xn["Content"]["Application"]["Container"]["HtmlName"].InnerText; CommentTitle = xn["Content"]["HtmlName"].InnerText; SitecoreItemId = CommentTitle.Substring(CommentTitle.IndexOf("{")); if (!string.IsNullOrEmpty(SitecoreItemId)) { CommentTitle = CommentTitle.Replace(SitecoreItemId, ""); } SitecoreItem = !string.IsNullOrEmpty(SitecoreItemId) ? Sitecore.Context.Database.GetItem(SitecoreItemId) : null; Type = xn["Content"]["Application"]["HtmlName"].InnerText; Url = SitecoreItem != null?SitecoreItem.GetUrl() : "/"; } }