public async Task <IActionResult> Edit(int id, [Bind("AlbumID,Name,NumSongs,Realease,ArtistID")] Album album) { if (id != album.AlbumID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(album); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AlbumExists(album.AlbumID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ArtistID"] = new SelectList(_context.Artists, "ArtistID", "Name", album.ArtistID); return(View(album)); }
public async Task <IActionResult> Edit(int id, [Bind("ArtistID,Name")] Artist artist) { if (id != artist.ArtistID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(artist); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ArtistExists(artist.ArtistID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(artist)); }