public ActionResult Create(Course course) { if (ModelState.IsValid) { db.Courses.Add(course); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.DepartmentID = new SelectList(db.Departments, "DepartmentID", "DepartmentID", course.DepartmentID); return View(course); }
public ActionResult Edit(Course course) { if (ModelState.IsValid) { db.Entry(course).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.DepartmentID = new SelectList(db.Departments, "DepartmentID", "DepartmentID", course.DepartmentID); return View(course); }