public async Task <IActionResult> Edit(int id, [Bind("Id,RetoId,EjercicioId")] EjercicioReto ejercicioReto) { if (id != ejercicioReto.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(ejercicioReto); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EjercicioRetoExists(ejercicioReto.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["EjercicioId"] = new SelectList(_context.Ejercicio, "Id", "Id", ejercicioReto.EjercicioId); ViewData["RetoId"] = new SelectList(_context.Set <Reto>(), "Id", "Id", ejercicioReto.RetoId); return(View(ejercicioReto)); }
public async Task <IActionResult> Create([Bind("Id,RetoId,EjercicioId")] EjercicioReto ejercicioReto) { if (ModelState.IsValid) { _context.Add(ejercicioReto); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["EjercicioId"] = new SelectList(_context.Ejercicio, "Id", "Id", ejercicioReto.EjercicioId); ViewData["RetoId"] = new SelectList(_context.Set <Reto>(), "Id", "Id", ejercicioReto.RetoId); return(View(ejercicioReto)); }