/// <summary> /// 获取最新trends /// </summary> /// <returns></returns> public List <Views.trends> GetNewTrends(int pageIndex, string token = "") { List <Views.trends> List = new List <Views.trends>(); DAL.course c = new DAL.course(); DataTable dt = c.GetListByPage(pageIndex, "", " time desc "); foreach (DataRow item in dt.Rows) { List.Add(c.DataRowToTrends(item, token)); } return(List); }
/// <summary> /// 返回搜索后的DataTable /// </summary> /// <param name="searchKey">搜索关键字</param> /// <param name="type">0图文 1视频</param> /// <returns></returns> public List <Views.course_T> GetListToSelect(int pageIndex, string searchKey, string type) { List <Views.course_T> list = new List <Views.course_T>(); StringBuilder strSql = new StringBuilder(); if (searchKey != "") { strSql.Append(" ( searchkey LIKE @key1 OR content LIKE @key2 ) "); strSql.Append(" and type = @type "); SqlParameter[] parameters = { new SqlParameter("@key1", SqlDbType.NVarChar, 250), new SqlParameter("@key2", SqlDbType.NVarChar, 250), new SqlParameter("@type", SqlDbType.Char, 1) }; parameters[0].Value = string.Format("%{0}%", searchKey.Trim()); parameters[1].Value = string.Format("%{0}%", searchKey.Trim()); parameters[2].Value = type.Trim(); DAL.course c = new DAL.course(); foreach (DataRow itme in c.GetListByPage(pageIndex, strSql.ToString(), parameters, " time desc").Rows) { list.Add(c.DataRowToModel_T(itme)); } return(list); } else { strSql.Append(" type = @type "); SqlParameter[] parameters = { new SqlParameter("@type", SqlDbType.Char, 1) }; parameters[0].Value = type.Trim(); DAL.course c = new DAL.course(); foreach (DataRow itme in c.GetListByPage(pageIndex, strSql.ToString(), parameters, " time desc").Rows) { list.Add(c.DataRowToModel_T(itme)); } return(list); } }
/// <summary> /// 获取动态信息 /// </summary> /// <param name="id"></param> /// <param name="pageIndex"></param> /// <returns></returns> public DataTable GetTrends(string id, int pageIndex) { //获取所有关注的人 DAL.follow_ folloew = new follow_(); DataRowCollection drs = folloew.GetList("", "", id).Rows; StringBuilder str = new StringBuilder(); for (int i = 0; i < drs.Count; i++) { if (i == 0) { str.AppendFormat(" authorid = {0} ", drs[i]["id"].ToString()); } else { str.AppendFormat(" or authorid = {0} ", drs[i]["id"].ToString()); } } //获取关注的人的教程信息 DAL.course course = new DAL.course(); return(course.GetListByPage(pageIndex, "(" + str.ToString() + ") and stats = 0 ", " time desc ")); }