public async Task <IActionResult> Edit(int id, [Bind("PeliculaId,PersonaId")] PeliculaActor peliculaActor) { if (id != peliculaActor.PersonaId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(peliculaActor); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PeliculaActorExists(peliculaActor.PersonaId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["PersonaId"] = new SelectList(_context.Personas, "Id", "Apellido", peliculaActor.PersonaId); ViewData["PeliculaId"] = new SelectList(_context.Peliculas, "Id", "Resumen", peliculaActor.PeliculaId); return(View(peliculaActor)); }
public async Task <IActionResult> Create([Bind("PeliculaId,PersonaId,PapelActor")] PeliculaActor peliculaActor) { if (ModelState.IsValid) { try { _context.Add(peliculaActor); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } catch (Exception ex) { ModelState.AddModelError(string.Empty, "La película ya contiene el actor elegido!"); } } ViewData["PersonaId"] = new SelectList(_context.Personas, "Id", "Apellido", peliculaActor.PersonaId); ViewData["PeliculaId"] = new SelectList(_context.Peliculas, "Id", "Titulo", peliculaActor.PeliculaId); return(View(peliculaActor)); }