Exemple #1
0
        /// <summary>
        /// 根据板块ID获得板块中的主题列表(分页)
        /// </summary>
        /// <param name="forumID">板块ID</param>
        /// <returns>主题列表</returns>
        public IList <ThreadsDspModel> GetForumThreadListByForumID(Guid forumID, int startIndex, int count)
        {
            IList <ThreadsDspModel> list = new List <ThreadsDspModel>();
            //创建主题仓储
            IForumThreadRepository forumThreadRep = FBS.Factory.Factory <IForumThreadRepository> .GetConcrete();

            IList <ForumThread> forumThreadList = forumThreadRep.GetThreadsInOneForum(forumID, startIndex, count);
            IAccountRepository  accRep          = FBS.Factory.Factory <IAccountRepository> .GetConcrete();

            //      return forumThreadRep.FindAll();

            foreach (ForumThread ft in forumThreadList)
            {
                ThreadsDspModel temp = new ThreadsDspModel();
                temp.ID           = ft.Id;
                temp.ClickCount   = ft.State.ClickCount;
                temp.MessageCount = ft.State.MessageCount;
                temp.Title        = ft.RootMessage.MessageVO.Subject;
                temp.UserID       = ft.RootMessage.Account;
                try
                {
                    temp.UserName = accRep.GetByKey(ft.RootMessage.Account).UserName;
                }
                catch (InvalidOperationException)
                {
                    temp.UserName = "******";
                }
                temp.LastModified = ft.State.ModifiedDate;
                temp.CreationDate = ft.CreationDate;
                temp.ForumID      = ft.ForumID;
                list.Add(temp);
            }
            return(list);
        }
Exemple #2
0
        /// <summary>
        /// 根据板块ID获得板块中所有的主题列表
        /// </summary>
        /// <param name="forumID"></param>
        /// <returns></returns>
        public IList <ThreadsDspModel> GetAllForumThreadListByForumID(Guid forumID)
        {
            IList <ThreadsDspModel> list = new List <ThreadsDspModel>();
            //创建主题仓储
            //IForumThreadRepository forumThreadRep = FBS.Factory.Factory<IForumThreadRepository>.GetConcrete();

            IForumThreadRepository forumThreadRep = Factory.Factory <IForumThreadRepository> .GetConcrete();

            IRepository <ForumMessage> msgRep = Factory.Factory <IRepository <ForumMessage> > .GetConcrete <ForumMessage>();

            //IList<ForumThread> forumThreadList = forumThreadRep.GetAllThreadsInOneForum(forumID);
            //IList<ForumThread> forumThreadList = forumThreadRep.FindAll(new Specification<ForumThread>(t => t.ForumID == forumID).OrderByDescending(t => t.CreationDate).Skip(0).Take(100));
            IList <ForumThread>   forumThreadList = forumThreadRep.GetThreadsInOneForum(forumID, 0, 100);
            IRepository <Account> accRep          = FBS.Factory.Factory <IRepository <Account> > .GetConcrete <Account>();

            foreach (ForumThread ft in forumThreadList)
            {
                ThreadsDspModel temp = new ThreadsDspModel();
                temp.ID           = ft.Id;
                temp.ClickCount   = ft.State.ClickCount;
                temp.MessageCount = ft.State.MessageCount;
                temp.Title        = ft.RootMessage.MessageVO.Subject;
                temp.UserID       = ft.RootMessage.Account;
                temp.ForumID      = ft.ForumID;
                try
                {
                    temp.UserName = accRep.GetByKey(ft.RootMessage.Account).UserName;
                }
                catch (InvalidOperationException)
                {
                    temp.UserName = "******";
                }
                temp.LastModified = ft.State.ModifiedDate;
                temp.CreationDate = ft.CreationDate;
                list.Add(temp);
            }
            return(list);
        }