public async Task <IActionResult> Edit(int id, [Bind("ID,SongID,ComposerID")] ComposerSong composerSong) { if (id != composerSong.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(composerSong); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ComposerSongExists(composerSong.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ComposerID"] = new SelectList(_context.Composer, "ID", "FullName", composerSong.ComposerID); ViewData["SongID"] = new SelectList(_context.Songs, "ID", "Name", composerSong.SongID); return(View(composerSong)); }
public async Task <IActionResult> Create([Bind("ID,SongID,ComposerID")] ComposerSong composerSong) { if (ModelState.IsValid) { _context.Add(composerSong); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ComposerID"] = new SelectList(_context.Composer, "ID", "FullName", composerSong.ComposerID); ViewData["SongID"] = new SelectList(_context.Songs, "ID", "Name", composerSong.SongID); return(View(composerSong)); }