public ActionResult Index() { ExamListViewModel elvm = new ExamListViewModel(); elvm.SideBarData = new SideBarViewModel(); elvm.SideBarData.CurrentIndex = 2; ExamListBusinessLayer examlistBusinessLayer = new ExamListBusinessLayer(); /* Code by Dwayne 2015-12-4 12:57:17 */ const int numPerPage = 5; int pageNum = Int32.Parse(RouteData.Values["id"].ToString()) - 1; List<ExamList> examList = examlistBusinessLayer.GetExamList(); elvm.ExamList = examList.Skip(pageNum * numPerPage).Take(numPerPage).ToList(); elvm.PageNum = pageNum; elvm.ExamNum = elvm.ExamList.Count; elvm.TotalNum = examList.Count; // 查找该年级的考试科目 加到ExamList中 Create by HuaFeng-Miki int GroupId = Convert.ToInt32(HttpContext.Session["Group"]); if (GroupId != 0) { foreach (ExamList examlist in examList) { if (examlist.Group == GroupId) { ExamList ShowExamlist = new ExamList(); ShowExamlist.ExamName = examlist.ExamName; ShowExamlist.Group = examlist.Group; ShowExamlist.StartTime = examlist.StartTime; ShowExamlist.Duration = examlist.Duration; elvm.ExamList.Add(ShowExamlist); } } } // Add default exam // Dwayne 2015-12-5 09:33:13 if (elvm.ExamNum == 0) { ExamList exam = new ExamList(); exam.ExamName = "Test"; exam.StartTime = DateTime.Now; exam.Group = 1; elvm.ExamList.Add(exam); elvm.ExamNum = elvm.TotalNum = 1; } if (HttpContext.Session["User"] != null && Session["User"].ToString() != "") { elvm.NavStatusData = new NavStatusViewModel(); elvm.NavStatusData.LeftLink = "/User/Profile/" + HttpContext.Session["User"].ToString(); elvm.NavStatusData.LeftText = Session["User"].ToString(); elvm.NavStatusData.RightLink = "/User/Logout"; elvm.NavStatusData.RightText = "Log out"; } return View("", elvm); }
// 展示考试列表 Create by HuaFeng-Miki public ActionResult ExamList() { ExamListViewModel examlistViewModel = new ExamListViewModel(); ExamListBusinessLayer examlistBusinessLayer = new ExamListBusinessLayer(); List<ExamList> examList = examlistBusinessLayer.GetExamList(); // 查找该年级的考试科目 加到ExamList中 Create by HuaFeng-Miki int GroupId = Convert.ToInt32(HttpContext.Session["Group"]); if (GroupId != 0) { foreach (ExamList examlist in examList) { if (examlist.Group == GroupId) { ExamList ShowExamlist = new ExamList(); ShowExamlist.ExamName = examlist.ExamName; ShowExamlist.Group = examlist.Group; ShowExamlist.StartTime = examlist.StartTime; ShowExamlist.Duration = examlist.Duration; examlistViewModel.ExamList.Add(ShowExamlist); } } } if (HttpContext.Session["User"] != null && Session["User"].ToString() != "") { examlistViewModel.NavStatusData = new NavStatusViewModel(); examlistViewModel.NavStatusData.LeftLink = "/User/Profile/" + HttpContext.Session["User"].ToString(); examlistViewModel.NavStatusData.LeftText = Session["User"].ToString(); examlistViewModel.NavStatusData.RightLink = "/User/Logout"; examlistViewModel.NavStatusData.RightText = "Log out"; } return View("ExamList", examlistViewModel); }