public ActionResult ListByTeacher() { using (var db = new XkSystem.Models.DbContext()) { var vm = new Models.ClassStudent.ListByTeacher(); vm.ClassList = ClassTeacherController.GetClassByClassTeacher(); if (vm.ClassId == 0 && vm.ClassList.Count > 0) { vm.ClassId = vm.ClassList.FirstOrDefault().Value.ConvertToInt(); } else { //return RedirectToAction(Url.Action("ListByTeacher", "OrgStudent", new { area = "Course" })); return(Redirect(Url.Action("ListByTeacher", "OrgStudent", new { area = "Course", IsClassTeacher = 2 }))); } if (vm.ClassId != 0) { var tb = from p in db.Table <Basis.Entity.tbClassStudent>() where p.tbClass.Id == vm.ClassId && p.tbStudent.IsDeleted == false select p; if (string.IsNullOrEmpty(vm.SearchText) == false) { tb = tb.Where(d => d.tbStudent.StudentCode.Contains(vm.SearchText) || d.tbStudent.StudentName.Contains(vm.SearchText)); } vm.ClassStudentList = (from p in tb orderby p.No, p.tbStudent.StudentCode select new Dto.ClassStudent.List { Id = p.Id, StudentId = p.tbStudent.Id, ClassId = p.tbClass.Id, ClassName = p.tbClass.ClassName, StudentCode = p.tbStudent.StudentCode, SexName = p.tbStudent.tbSysUser.tbSex.SexName, No = p.No, ClassGroupName = p.tbClassGroup.ClassGroupName, StudentName = p.tbStudent.StudentName }).ToList(); } return(View(vm)); } }
public ActionResult ListByTeacher(Models.ClassStudent.ListByTeacher vm) { return(Code.MvcHelper.Post(null, Url.Action("ListByTeacher", new { classId = vm.ClassId, searchText = vm.SearchText }))); }