public async Task <IActionResult> Edit(int id, [Bind("Id,StartDateTime,EndDateTime,SportId,WorkoutDuration,WorkoutDistance")] PROWorkouts pROWorkouts) { if (id != pROWorkouts.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(pROWorkouts); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PROWorkoutsExists(pROWorkouts.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["SportId"] = new SelectList(_context.Sport, "Id", "Id", pROWorkouts.SportId); return(View(pROWorkouts)); }
public async Task <IActionResult> Create([Bind("Id,StartDateTime,EndDateTime,SportId,WorkoutDuration,WorkoutDistance")] PROWorkouts pROWorkouts) { if (ModelState.IsValid) { _context.Add(pROWorkouts); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["SportId"] = new SelectList(_context.Sport, "Id", "Id", pROWorkouts.SportId); return(View(pROWorkouts)); }