public ActionResult Create([Bind(Include = "StudentID, StudentName, ClassID")] CreateStudentViewModel vm)
 {
     if (ModelState.IsValid)
     {
         repo.AddStudent(vm);
         return(RedirectToAction("Index"));
     }
     return(View(vm));
 }
Example #2
0
        public ActionResult Create([Bind(Include = "StudentID,StudentName,ClassID")] Student student)
        {
            if (ModelState.IsValid)
            {
                repo.AddStudent(student);
                return(RedirectToAction("Index"));
            }

            ViewBag.ClassID = new SelectList(repo.GetAllClasses(), "ClassID", "ClassName", student.ClassID);
            return(View(student));
        }