public CourseListRS GetCourses(CourseListRQ rq) { if (rq == null || rq.pageIndex <= 0 || rq.pageSize <= 0) { return new CourseListRS { total = 0, list = null } } ; return(_service.GetCourses(rq)); }
/// <summary> /// 课程管理列表 /// </summary> /// <param name="rq"></param> /// <returns></returns> public CourseListRS GetCourses(CourseListRQ rq) { var result = new CourseListRS { total = 0, list = null }; var sql = string.Empty; //"select * from Course where 1=1 "; if (!string.IsNullOrWhiteSpace(rq.paraName)) { sql += string.Format(" (Name like '%{0}%' or Title like '%{0}%') ", rq.paraName); } var user = Course.FindAll(sql, "Id desc", null, (rq.pageIndex - 1) * rq.pageSize, rq.pageSize); var query = (from a in user.ToList() select new { a.Id, a.Conent, a.ImageUrl, a.IsRecomand, a.Name, a.Title, a.CreatedByName, a.CreatedOn, a.ModifiedByName, a.ModifiedOn, a.Status, }); query = query.OrderByDescending(q => q.ModifiedOn).ThenByDescending(q => q.Id); result.total = Course.FindAll(sql, null, null, 0, 0).Count; //query.Count(); if (result.total == 0) { return(result); } result.list = query.Select(a => new CourseListItemRS { Id = a.Id, Conent = a.Conent, ImageUrl = a.ImageUrl, IsRecomand = a.IsRecomand, Name = a.Name, Title = a.Title, ModifiedOn = a.ModifiedOn, ModifiedByName = a.ModifiedByName, Status = a.Status, CreatedOn = a.CreatedOn, CreatedByName = a.CreatedByName }).ToList(); return(result); }