// // GET: /Course/Create public ActionResult Create() { var subjects = _repo.Subjects.All; var faculties = _repo.Faculties.All; var course = new Course(); var vm = new CourseInputModel(course, subjects, faculties); return View(vm); }
public ActionResult Edit(int id, Course course) { try { if (ModelState.IsValid) { var item = _repo.Courses.All.FirstOrDefault(c => c.Id == id); item.Name = course.Name; item.Code = course.Code; item.Start = course.Start; item.Credit = course.Credit; item.FacultyId = course.FacultyId; item.SubjectId = course.SubjectId; _repo.SaveChanges(); return RedirectToAction("Index"); } var subjects = _repo.Subjects.All; var faculties = _repo.Faculties.All; var vm = new CourseInputModel(course, subjects, faculties); return View(vm); } catch { return View(); } }
// // GET: /Course/Edit/5 public ActionResult Edit(int id) { var subjects = _repo.Subjects.All; var faculties = _repo.Faculties.All; var course = _repo.Courses.All.First(c => c.Id == id); var vm = new CourseInputModel(course, subjects, faculties); return View(vm); }