示例#1
0
        public ActionResult IndexUniver()
        {
            UniverContext uc = new UniverContext();

            ViewBag.Students = uc.Students.ToList();
            ViewBag.Courses = uc.Courses.ToList();
            return View();
        }
示例#2
0
        public ActionResult StudentEdit(Student st, int[] selectedCourses)
        {
            UniverContext uc = new UniverContext();

            uc.Entry(st).State = EntityState.Modified;
            uc.SaveChanges();

            return RedirectToAction("StudentDetails",new { id = st.Id});
        }
示例#3
0
        public ActionResult StudentDetails(int? Id)
        {
            UniverContext uc = new UniverContext();
            Student st = uc.Students.Find(Id);

            return View(st);
        }
示例#4
0
        public ActionResult StudentEdit(int? Id)
        {
            UniverContext uc = new UniverContext();
            EditModel em = new EditModel();

            em.Courses = sl(uc);
            em.Student = uc.Students.Find(Id);

            ViewBag.UC = new MultiSelectList(uc.Courses.Select(c => new { Name = c.Name }).ToList(),"Name");
            return View(em);
        }
示例#5
0
        public IEnumerable<SelectListItem> sl(UniverContext uc_)
        {
            List<SelectListItem> sellist = new List<SelectListItem>();

            foreach(Course cs in uc_.Courses)
            {
                sellist.Add(new SelectListItem { Text = cs.Name });
            }

            return sellist;
        }