public ActionResult Create([Bind(Include = "CourseName,Description,TeacherId")] Course course) { if (ModelState.IsValid) { courseRepo.InsertOrUpdate(course); return RedirectToAction("Index"); } var model = new CreateCourseViewModel { CourseId = course.CourseId, CourseName = course.CourseName, Description = course.Description }; return View(model); }
// GET: Curricula/Edit/5 public ActionResult Edit(int? id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } Course course = courseRepo.Find((int) id); var model = new CreateCourseViewModel { CourseId = (int) id, CourseName = course.CourseName, Description = course.Description }; if (course == null) { return HttpNotFound(); } return View(model); }
// GET: Courses/Create public ActionResult Create() { var model = new CreateCourseViewModel {}; return View(model); }