Beispiel #1
0
        /// <summary>
        /// 根据类型获取问题列表
        /// </summary>
        /// <param name="id"></param>
        /// <param name="questionPage"></param>
        /// <param name="keyWords">关键词</param>
        /// <returns></returns>
        public List <_QuestionInfo> GetQuestionList(int id, Paging questionPage, string keyWords = null, long tagId = 0)
        {
            DataSet ds = dal.GetQuestionList(id, questionPage.StartIndex, questionPage.EndIndex, keyWords, tagId);
            List <_QuestionInfo> list = new List <_QuestionInfo>();

            if (keyWords.IsNotNullOrEmpty() || tagId > 0)
            {
                questionPage.RecordCount = Convert.ToInt32(ds.Tables[0].Rows[0][0]);
                list.AddRange(ModelConvertHelper <_QuestionInfo> .ConvertToList(ds.Tables[1]).OrderByDescending(a => Convert.ToDateTime(a.CreateTime).ToString("yyyy-MM-dd")).ThenByDescending(a => a.PVCount).ToList());
            }
            else
            {
                questionPage.RecordCount = Convert.ToInt32(ds.Tables[1].Rows[0][0]);
                //如果不是第一页,则不加载置顶、精华等数据
                if (questionPage.PageIndex == 1)
                {
                    list.AddRange(ModelConvertHelper <_QuestionInfo> .ConvertToList(ds.Tables[0]).OrderByDescending(a => Convert.ToDateTime(a.CreateTime).ToString("yyyy-MM-dd")).ThenByDescending(a => a.PVCount).ToList());
                }
                list.AddRange(ModelConvertHelper <_QuestionInfo> .ConvertToList(ds.Tables[2]).OrderByDescending(a => Convert.ToDateTime(a.CreateTime).ToString("yyyy-MM-dd")).ThenByDescending(a => a.PVCount).ToList());
            }
            return(list);
        }