public ActionResult Index(BasePagerModel pager) { if (!User.Identity.IsAuthenticated) { return(RedirectToRoute(new { controller = "Login", action = "LogOut" })); } int uid = PageValidate.FilterParam(User.Identity.Name); if (!RoleCheck.CheckHasAuthority(uid, db, "用户管理")) { return(RedirectToRoute(new { controller = "Error", action = "Index", err = "没有权限。" })); } if (pager == null) { pager = new BasePagerModel(); } ViewData["search"] = pager; var list = (from user in db.User_Info join uvr in db.User_vs_Role on user.user_id equals uvr.uvr_user_id into T1 from t1 in T1.DefaultIfEmpty() join role in db.Dic_Role on t1.uvr_role_id equals role.role_id into T2 from t2 in T2.DefaultIfEmpty() join ue in db.User_Extend on user.user_id equals ue.user_id into T3 from t3 in T3.DefaultIfEmpty() join dept in db.Dic_Department on t3.user_dept_id equals dept.dept_id into T4 from t4 in T4.DefaultIfEmpty() join post in db.Dic_Post on t3.user_post_id equals post.post_id into T5 from t5 in T5.DefaultIfEmpty() orderby user.user_id ascending select new UserListModel { id = user.user_id, name = user.user_name, roleName = t2.role_name == null?"":t2.role_name, stateTxt = user.user_state == 1 ? "正常" : (user.user_state == 2 ? "锁定" : (user.user_state == 0 ? "未启用" : "未知")), realName = user.real_name, times = user.user_login_times, deptName = t4.dept_name == null?"":t4.dept_name, postName = t5.post_name == null?"":t5.post_name, picture = t3.user_picture == null?"default.jpg":t3.user_picture, loginTimes = user.user_login_times }).Skip((pager.PageIndex - 1) * pager.PageSize).Take(pager.PageSize).ToList(); foreach (var item in list) { item.realName = Common.DEncrypt.AESEncrypt.Decrypt(item.realName); } return(View(list)); }
List <CourseModel> SearchCourse(PageInfo pageInfo) { CreateSelect(); var courses = (from c in db.Course_Infos join r in db.Sys_ClassRooms on c.c_room equals r.room_id into T1 from t1 in T1.DefaultIfEmpty() join s in db.Sys_Schools on t1.room_school_id equals s.sys_school_id into T2 from t2 in T2.DefaultIfEmpty() join ty in db.Dic_Course_Types on c.c_type_id equals ty.ct_id into T3 from t3 in T3.DefaultIfEmpty() join tea in db.User_Infos on c.c_teacher_id equals tea.user_id into T4 from t4 in T4.DefaultIfEmpty() join ass in db.User_Infos on c.c_assistant_id equals ass.user_id into T5 from t5 in T5.DefaultIfEmpty() join season in db.Course_Seasons on c.c_cs_id equals season.c_season_id into T6 from t6 in T6.DefaultIfEmpty() join sub in db.Dic_Subjects on c.c_sub_id equals sub.sub_id into T7 from t7 in T7.DefaultIfEmpty() where t1.room_school_id == (pageInfo.school == 0 ? t1.room_school_id : pageInfo.school) orderby new { c.c_cs_id, c.c_sub_id, c.course_name } select new CourseModel { id = c.course_id, assistantName = t5.user_name, cost = c.course_cost, introduce = c.course_introduce, max = c.course_max_num, name = c.course_name, room = c.c_room, roomName = t1.room_id == 0 ? "" : t2.sys_school_name + t1.room_name, season = c.c_cs_id, seasonName = t6.c_season_name, subject = c.c_sub_id, subjectName = t7.sub_name, teacher = c.c_teacher_id, teacherName = t4.user_name, type = c.c_type_id, typeName = t3.ct_name, timeInfo = c.c_time_info }); //.Skip(pagesize*(pageindex-1)).Take(pagesize).ToList(); if (pageInfo.room != 0) { courses = courses.Where(x => x.room == pageInfo.room); } if (pageInfo.season != 0) { courses = courses.Where(x => x.season == pageInfo.season); } if (pageInfo.subject != 0) { courses = courses.Where(x => x.subject == pageInfo.subject); } if (pageInfo.teacher != 0) { courses = courses.Where(x => x.teacher == pageInfo.teacher); } if (pageInfo.type != 0) { courses = courses.Where(x => x.type == pageInfo.type); } if (!string.IsNullOrEmpty(pageInfo.keyword)) { courses = courses.Where(x => x.name.Contains(pageInfo.keyword)); } pageInfo.count = courses.Count(); if (pageInfo.pagesize == 0) { pageInfo.pagesize = 10; } if (pageInfo.pageindex == 0) { pageInfo.pageindex = 1; } pageInfo.pages = (int)Math.Ceiling((decimal)pageInfo.count / pageInfo.pagesize); ViewData["search"] = pageInfo; var list = courses.Skip(pageInfo.pagesize * (pageInfo.pageindex - 1)).Take(pageInfo.pagesize).ToList(); foreach (var course in list) { var time = (from cvt in db.Course_vs_Times where cvt.cvt_course_id == course.id orderby cvt.cvt_time ascending select cvt.cvt_time ).FirstOrDefault(); course.beginDate = time; } return(list); }