public ActionResult ScheduleCourseList(int examId, int scheduleId) { using (var db = new XkSystem.Models.DbContext()) { var vm = new Models.ExamSchedule.List(); var tb = (from p in db.Table <Exam.Entity.tbExamCourse>() where p.tbCourse.IsDeleted == false && p.tbCourse.tbSubject.IsDeleted == false && p.tbExam.Id == examId && p.tbExamSchedule.Id == scheduleId select p); vm.ExamScheduleList = (from p in tb select new Dto.ExamSchedule.List { Id = p.Id, SubjectName = p.tbCourse.tbSubject.SubjectName, CourseName = p.tbCourse.CourseName }).ToList(); return(View(vm)); } }
public ActionResult List() { using (var db = new XkSystem.Models.DbContext()) { var vm = new Models.ExamSchedule.List(); vm.ExamList = Exam.Controllers.ExamController.SelectList(); if (vm.ExamId == 0 && vm.ExamList.Count > 0) { vm.ExamId = vm.ExamList.FirstOrDefault().Value.ConvertToInt(); } var tb = from p in db.Table <Exam.Entity.tbExamSchedule>() where p.tbExam.IsDeleted == false && (vm.ExamId == 0 || p.tbExam.Id == vm.ExamId) select p; if (string.IsNullOrEmpty(vm.SearchText) == false) { tb = tb.Where(d => d.ExamScheduleName.Contains(vm.SearchText)); } vm.ExamScheduleList = (from p in tb orderby p.ScheduleDate, p.ScheduleNo select new Dto.ExamSchedule.List { Id = p.Id, ExamScheduleName = p.ExamScheduleName, ScheduleNo = p.ScheduleNo, ScheduleDate = p.ScheduleDate, FromDate = p.FromDate, ToDate = p.ToDate, ExamName = p.tbExam.ExamName, }).ToList(); return(View(vm)); } }
public ActionResult MyExamRoomList() { using (var db = new XkSystem.Models.DbContext()) { var vm = new Models.ExamSchedule.List(); vm.ExamList = Exam.Controllers.ExamController.SelectList(); if (vm.ExamId == 0 && vm.ExamList.Count > 0) { vm.ExamId = vm.ExamList.FirstOrDefault().Value.ConvertToInt(); } var tb = from p in db.Table <Exam.Entity.tbExamSchedule>() where p.tbExam.IsDeleted == false && (vm.ExamId == 0 || p.tbExam.Id == vm.ExamId) select p; if (string.IsNullOrEmpty(vm.SearchText) == false) { tb = tb.Where(d => d.ExamScheduleName.Contains(vm.SearchText)); } //场次考试日期 var lst = new List <string>(); foreach (var o in tb.Select(d => d.ScheduleDate).Distinct().OrderBy(d => d)) { var scheduleDate = o.ToString(Code.Common.StringToDate); lst.Add(scheduleDate); } vm.columnList = lst; //场次课程 var examScheduleCouseList = (from p in db.Table <Exam.Entity.tbExamCourse>() where p.tbExam.Id == vm.ExamId && p.tbCourse.IsDeleted == false && p.tbExamSchedule.IsDeleted == false select new { ScheduleId = p.tbExamSchedule.Id, p.tbExamSchedule.ScheduleDate, p.tbExamSchedule.ScheduleNo, FromDate = p.tbExamSchedule.FromDate, ToDate = p.tbExamSchedule.ToDate, ExamCourseId = p.Id, p.tbCourse.CourseName }).Distinct().ToList(); //课程考场 var examRoomList = (from p in db.Table <Exam.Entity.tbExamRoom>() where p.tbExamCourse.IsDeleted == false && p.tbRoom.IsDeleted == false select new { ExamCourseId = p.tbExamCourse.Id, ExamRoomId = p.Id, p.tbRoom.RoomName, p.ExamRoomName }).ToList(); var lstExamRoom = new List <int>(); if (Code.Common.UserType == Code.EnumHelper.SysUserType.Student) { //考场学生 lstExamRoom = (from p in db.Table <Exam.Entity.tbExamStudent>() where p.tbStudent.IsDeleted == false && p.tbExamRoom.IsDeleted == false && p.tbStudent.tbSysUser.Id == Code.Common.UserId select p.tbExamRoom.Id).Distinct().ToList(); } else if (Code.Common.UserType == Code.EnumHelper.SysUserType.Teacher || Code.Common.UserType == Code.EnumHelper.SysUserType.Administrator) { //监考教师 lstExamRoom = (from p in db.Table <Exam.Entity.tbExamTeacher>() where p.tbExamRoom.IsDeleted == false && p.tbTeacher.tbSysUser.Id == Code.Common.UserId select p.tbExamRoom.Id).Distinct().ToList(); } vm.ScheduleRoomList = (from p in examScheduleCouseList join t in examRoomList on p.ExamCourseId equals t.ExamCourseId where lstExamRoom.Contains(t.ExamRoomId) select new Dto.ExamSchedule.ScheduleRoomList { ScheduleId = p.ScheduleId, ScheduleDate = p.ScheduleDate, ScheduleNo = p.ScheduleNo, ExamCourseId = p.ExamCourseId, ExamRoomId = t.ExamRoomId, FromDate = p.FromDate, ToDate = p.ToDate, CourseName = p.CourseName, ExamRoomName = t.ExamRoomName, RoomName = t.RoomName }).ToList(); vm.ExamRoomCourseList = (from p in vm.ScheduleRoomList select new Dto.ExamSchedule.ScheduleRoomList { ExamCourseId = p.ExamCourseId, ExamRoomId = p.ExamRoomId, ScheduleNo = p.ScheduleNo }).Distinct().ToList(); vm.ExamScheduleList = (from p in tb orderby p.ScheduleNo select new Dto.ExamSchedule.List { ScheduleNo = p.ScheduleNo, }).Distinct().ToList(); return(View(vm)); } }
public ActionResult MyExamRoomList(Models.ExamSchedule.List vm) { return(Code.MvcHelper.Post(null, Url.Action("MyExamRoomList", new { searchText = vm.SearchText, examId = vm.ExamId }))); }