コード例 #1
0
 public ExamList AddExamlist(ExamList examlist)
 {
     OTSDBDAL otsdbDAL = new OTSDBDAL();
     otsdbDAL.ExamList.Add(examlist);
     otsdbDAL.SaveChanges();
     return examlist;
 }
コード例 #2
0
        public ExamList AddExamlist(ExamList examlist)
        {
            OTSDBDAL otsdbDAL = new OTSDBDAL();

            otsdbDAL.ExamList.Add(examlist);
            otsdbDAL.SaveChanges();
            return(examlist);
        }
コード例 #3
0
        public ActionResult UploadExam()
        {
            AddExamViewModel aevm = new AddExamViewModel();
            aevm.SideBarData = new SideBarViewModel();
            aevm.SideBarData.CurrentIndex = 2;
            ExamBusinessLayer EBL = new ExamBusinessLayer();
            ExamListBusinessLayer list = new ExamListBusinessLayer();
            ExamList AddToExamLit = new ExamList();
            /* Business code here. */
            if (HttpContext.Session["Mail"].ToString()=="*****@*****.**")
            {
                HttpPostedFileBase examFile = Request.Files["examFile"];
                List<Exam> examList = new List<Exam>();

                if (examFile != null)
                {
                    examList = FileTrans(examFile);
                    if (examList != null)
                    {
                        EBL.AddExam(examList);
                        AddToExamLit.Duration = 60;
                        AddToExamLit.Group = 1;
                        AddToExamLit.ExamName = examList[0].ExamName.Split('\0')[0];

                        AddToExamLit.StartTime = DateTime.Now;
                        list.AddExamlist(AddToExamLit);
                        /* if success then */
                        aevm.Message = "Add Exam successfully!";
                        aevm.AlertType = "success";
                    }
                    else
                    {
                        /* if not success then */
                        aevm.Message = "Fail to add Exam.";
                        aevm.AlertType = "danger";
                    }
                }

            }
            else
            {
                Response.Redirect("~");
                return View("");
            }

            if (HttpContext.Session["User"] != null && Session["User"].ToString() != "")
            {
                aevm.NavStatusData = new NavStatusViewModel();
                aevm.NavStatusData.LeftLink = "/User/Profile/" + HttpContext.Session["User"].ToString();
                aevm.NavStatusData.LeftText = Session["User"].ToString();
                aevm.NavStatusData.RightLink = "/User/Logout";
                aevm.NavStatusData.RightText = "Log out";
            }

            return View("Add", aevm);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        // 展示考试列表  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);
        }