//public ThreadModel(string forumID, string threadID, Func<string, string, XmlNode> fun = null) //{ // XmlNode node=null; // if (fun == null) // node = CommunityHelper.ReadThread(forumID, threadID); // else // node = fun(forumID, threadID); // Initialize(node); // } public void Initialize(XmlNode childNode) { if (childNode != null) { ThreadID = childNode.SelectSingleNode("Id").InnerText; ForumID = childNode.SelectSingleNode("ForumId").InnerText; // TODO: Complete member initialization //this.childNode = childNode; Subject = childNode.SelectSingleNode("Subject").InnerText; ReplyCount = childNode.SelectSingleNode("ReplyCount").InnerText ?? "0"; LastPostDate = Convert.ToDateTime(childNode.SelectSingleNode("LatestPostDate").InnerText); LastPostTime = formatDateFunc(childNode.SelectSingleNode("LatestPostDate").InnerText); if (!ReplyCount.Equals("0")) { LastPostUser = Replies.OrderByDescending(x => x.Date).First().AuthorName; LastPostBody = Replies.OrderByDescending(x => x.Date).First().Body; } StartedBy = childNode.SelectSingleNode("Author/Username").InnerText ?? "admin"; Snippet = formatBodyFunc(childNode.SelectSingleNode("Body").InnerText); Body = childNode.SelectSingleNode("Body").InnerText; ContentId = childNode.SelectSingleNode("ContentId").InnerText; ContentTypeId = childNode.SelectSingleNode("ContentTypeId").InnerText; } else { throw new Exception("Null object"); } }
public Report SortReplies() { Replies = Replies.OrderByDescending(r => r.DateSent).ToList(); return(this); }