public async Task <IActionResult> Edit(int id, [Bind("ProgressId,WorkoutDate,WeightUsed,Repititions,ExerciseId")] LiftingProgress liftingProgress) { if (id != liftingProgress.ProgressId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(liftingProgress); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LiftingProgressExists(liftingProgress.ProgressId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ExerciseName"] = new SelectList(_context.Exercises, "Exercise", "Exercise", liftingProgress.Exercise.ExerciseName); return(View(liftingProgress)); }
public async Task <IActionResult> Create([Bind("ProgressId,WorkoutDate,WeightUsed,Repititions,ExerciseId")] LiftingProgress liftingProgress) { if (ModelState.IsValid) { _context.Add(liftingProgress); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } using (var ex = new WeightLiftingDbContext()) { var exerciseNames = _context.Exercises .Include(exer => exer.ExerciseName) .ToListAsync(); } //object v = ViewData["ExerciseId"] = new SelectList(exerciseNames, "Exercise Name", dataTextField: "Exercise Name", exerciseNames); return(View(liftingProgress)); }