public IActionResult Create([Bind("Album_ID,ArtistName,Track,AlbumCoverPath,Genre")] AlbumsDTO albumsDTO) { var albums = new Albums() { Album_ID = albumsDTO.Album_ID, ArtistName = albumsDTO.ArtistName, Track = albumsDTO.Track, AlbumCoverPath = albumsDTO.AlbumCoverPath, Genre = albumsDTO.Genre //// Start here from NetChicken https://github.com/Netchicken/VisistorManagment2019Students/blob/master/Controllers/StaffNamesController.cs // Names next }; if (ModelState.IsValid) { _context.Add(albums); _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(albumsDTO)); }
public async Task <IActionResult> Edit(int id, [Bind("Album_ID,ArtistName,Track,AlbumCoverPath,Genre")] AlbumsDTO albumsDTO) { if (id != albumsDTO.Album_ID) { return(NotFound()); } var albums = new Albums() { Album_ID = albumsDTO.Album_ID, ArtistName = albumsDTO.ArtistName, Track = albumsDTO.Track, AlbumCoverPath = albumsDTO.AlbumCoverPath,// this will not be used on the web page Genre = albumsDTO.Genre }; if (ModelState.IsValid) { try { _context.Update(albums); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AlbumsExists(albums.Album_ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(albumsDTO)); }