public ActionResult Create(Course course) { if (ModelState.IsValid) { //course.AssignedTo = "Yet Not Assigned "; db.CourseDbSet.Add(course); if (db.SaveChanges() > 0) ViewBag.Message = "Course :- " + course.CourseName + " has been saved successfully ."; ViewBag.DepartmentID = new SelectList(db.DepartmentDbSet, "DepartmentID", "DeptCode", course.DepartmentID); ViewBag.SemesterID = new SelectList(db.SemesterDbSet, "SemesterID", "SemesterName", course.SemesterID); return View(course); } ViewBag.DepartmentID = new SelectList(db.DepartmentDbSet, "DepartmentID", "DeptCode", course.DepartmentID); ViewBag.SemesterID = new SelectList(db.SemesterDbSet, "SemesterID", "SemesterName", course.SemesterID); 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.DepartmentDbSet, "DepartmentID", "DeptCode", course.DepartmentID); ViewBag.SemesterID = new SelectList(db.SemesterDbSet, "SemesterID", "SemesterName", course.SemesterID); return View(course); }