示例#1
0
        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);
        }
示例#2
0
 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);
 }