public async Task <IActionResult> Edit(int id, [Bind("Id,FilmId,ArtistId,Description")] FilmArtist filmArtist) { if (id != filmArtist.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(filmArtist); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FilmArtistExists(filmArtist.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ArtistId"] = new SelectList(_context.Artist, "ArtistId", "Name", filmArtist.ArtistId); ViewData["FilmId"] = new SelectList(_context.Film, "FilmId", "Name", filmArtist.FilmId); return(View(filmArtist)); }
public async Task <IActionResult> Create([Bind("Id,FilmId,ArtistId,Description")] FilmArtist filmArtist) { if (ModelState.IsValid) { _context.Add(filmArtist); await _context.SaveChangesAsync(); return(RedirectToAction("Index", "FilmArtists")); } ViewData["FilmId"] = new SelectList(_context.Film, "FilmId", "Name", filmArtist.FilmId); ViewData["ArtistId"] = new SelectList(_context.Artist, "ArtistId", "Name", filmArtist.ArtistId); return(View(filmArtist)); }