public ActionResult Create(ExerciseUnit exerciseunit) { if (ModelState.IsValid) { db.ExerciseUnits.Add(exerciseunit); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.exerciseId = new SelectList(db.Exercises, "id", "name", exerciseunit.exerciseId); ViewBag.workoutId = new SelectList(db.Workouts, "id", "name", exerciseunit.workoutId); return View(exerciseunit); }
public ActionResult Edit(ExerciseUnit exerciseunit) { if (ModelState.IsValid) { db.Entry(exerciseunit).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.exerciseId = new SelectList(db.Exercises, "id", "name", exerciseunit.exerciseId); ViewBag.workoutId = new SelectList(db.Workouts, "id", "name", exerciseunit.workoutId); return View(exerciseunit); }