public ActionResult List() { using (var db = new XkSystem.Models.DbContext()) { var vm = new Models.Study.List(); vm.YearList = Basis.Controllers.YearController.SelectList(Code.EnumHelper.YearType.Section); var IsRoomList = new List <System.Web.Mvc.SelectListItem>(); IsRoomList.Add(new SelectListItem { Text = "全部", Value = "0" }); IsRoomList.Add(new SelectListItem { Text = "教室模式", Value = "1" }); IsRoomList.Add(new SelectListItem { Text = "班级模式", Value = "2" }); vm.IsRoomList = IsRoomList; if (vm.YearList.Count > 0 && vm.YearId == 0) { vm.YearId = vm.YearList.OrderByDescending(d => d.Selected).FirstOrDefault().Value.ConvertToInt(); } var tb = from p in db.Table <Study.Entity.tbStudy>() select p; if (vm.YearId != 0) { tb = tb.Where(d => d.tbYear.Id == vm.YearId); } if (vm.IsRoomId != 0) { tb = tb.Where(d => d.IsRoom == (vm.IsRoomId == 2 ? false : true)); } if (string.IsNullOrEmpty(vm.SearchText) == false) { tb = tb.Where(d => d.StudyName.Contains(vm.SearchText)); } vm.StudyList = (from p in tb orderby p.Id descending select new Dto.Study.List { Id = p.Id, No = p.No, IsApply = p.IsApply, IsRoom = p.IsRoom, StudyName = p.StudyName, YearName = p.tbYear.YearName, ApplyFrom = p.ApplyFrom, ApplyTo = p.ApplyTo }).ToPageList(vm.Page); return(View(vm)); } }
public ActionResult List(Models.Study.List vm) { return(Code.MvcHelper.Post(null, Url.Action("List", new { searchText = vm.SearchText, yearId = vm.YearId, isRoomId = vm.IsRoomId, pageSize = vm.Page.PageSize, pageCount = vm.Page.PageCount, pageIndex = vm.Page.PageIndex }))); }