public async Task <IActionResult> Edit(int id, [Bind("ArtistId,Name,Popularity,Genres")] 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)); }
public async Task <IActionResult> Edit(int id, [Bind("AlbumId,Name,ReleaseDate,Rating,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)); }