/// <summary> /// Get a simple forum/topic listing. /// </summary> /// <param name="boardId"> The board Id. </param> /// <param name="userId"> The user Id. </param> /// <param name="timeFrame"> The time Frame. </param> /// <param name="maxCount"> The max Count. </param> /// <returns> The get simple forum topic. </returns> public List <SimpleForum> GetSimpleForumTopic(int boardId, int userId, DateTime timeFrame, int maxCount) { var forumData = this.DbFunction .GetAsDataTable(cdb => cdb.forum_listall(boardId, userId)) .SelectTypedList(x => new SimpleForum { ForumID = x.Field <int>("ForumID"), Name = x.Field <string>("Forum") }) .ToList(); // get topics for all forums... foreach (var forum in forumData) { SimpleForum forum1 = forum; // add topics var topics = LegacyDb.topic_list(forum1.ForumID, userId, timeFrame, DateTime.UtcNow, 0, maxCount, false, false, false).AsEnumerable(); // filter first... forum.Topics = topics.Where(x => x.Field <DateTime>("LastPosted") >= timeFrame) .Select(x => this.LoadSimpleTopic(x, forum1)) .ToList(); } return(forumData); }
private SimpleTopic LoadSimpleTopic([NotNull] DataRow row, [NotNull] SimpleForum forum) { CodeContracts.VerifyNotNull(row, "row"); CodeContracts.VerifyNotNull(forum, "forum"); return(new SimpleTopic { TopicID = row.Field <int>("TopicID"), CreatedDate = row.Field <DateTime>("Posted"), Subject = row.Field <string>("Subject"), StartedUserID = row.Field <int>("UserID"), StartedUserName = UserMembershipHelper.GetDisplayNameFromID(row.Field <int>("UserID")), Replies = row.Field <int>("Replies"), LastPostDate = row.Field <DateTime>("LastPosted"), LastUserID = row.Field <int>("LastUserID"), LastUserName = UserMembershipHelper.GetDisplayNameFromID(row.Field <int>("LastUserID")), LastMessageID = row.Field <int>("LastMessageID"), FirstMessage = row.Field <string>("FirstMessage"), LastMessage = LegacyDb.MessageList(row.Field <int>("LastMessageID")).First().Message, Forum = forum }); }
private SimpleTopic LoadSimpleTopic([NotNull] PagedTopic topic, [NotNull] SimpleForum forum) { CodeContracts.VerifyNotNull(forum, "forum"); return(new SimpleTopic { TopicID = topic.TopicID, CreatedDate = topic.Posted, Subject = topic.Subject, StartedUserID = topic.UserID, StartedUserName = this.Get <BoardSettings>().EnableDisplayName ? topic.StarterDisplay : topic.Starter, Replies = topic.Replies, LastPostDate = topic.LastPosted.Value, LastUserID = topic.LastUserID.Value, LastUserName = this.Get <BoardSettings>().EnableDisplayName ? topic.LastUserDisplayName : topic.LastUserName, LastMessageID = topic.LastMessageID.Value, FirstMessage = topic.FirstMessage, LastMessage = this.GetRepository <Message>().GetById(topic.LastMessageID.Value).MessageText, Forum = forum }); }
private SimpleTopic LoadSimpleTopic([NotNull] DataRow row, [NotNull] SimpleForum forum) { CodeContracts.VerifyNotNull(row, "row"); CodeContracts.VerifyNotNull(forum, "forum"); return(new SimpleTopic { TopicID = row.Field <int>("TopicID"), CreatedDate = row.Field <System.DateTime>("Posted"), Subject = row.Field <string>("Subject"), StartedUserID = row.Field <int>("UserID"), StartedUserName = this.Get <IUserDisplayName>().GetName(row.Field <int>("UserID")), Replies = row.Field <int>("Replies"), LastPostDate = row.Field <System.DateTime>("LastPosted"), LastUserID = row.Field <int>("LastUserID"), LastUserName = this.Get <IUserDisplayName>().GetName(row.Field <int>("LastUserID")), LastMessageID = row.Field <int>("LastMessageID"), FirstMessage = row.Field <string>("FirstMessage"), LastMessage = this.GetRepository <Message>().GetById(row.Field <int>("LastMessageID")).MessageText, Forum = forum }); }