public async Task <IActionResult> Edit(int id, [Bind("ID,Title,GenreID,AlbumID")] Song song) { if (id != song.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(song); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SongExists(song.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } PopulateAlbumDropdown(song); PopulateGenreDropdown(song); return(View(song)); }
public async Task <IActionResult> Edit(int id, [Bind("ID,Name")] Genre genre) { if (id != genre.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(genre); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!GenreExists(genre.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(genre)); }