public IActionResult Delete(int id) { var product = _musicStoreContext.Products.Single(p => p.Id == id); _musicStoreContext.Remove(product); _musicStoreContext.SaveChanges(); return(RedirectToAction("Index")); }
public async Task DeleteAsync(string genre) { var dbGenre = await _context.Genres .Include(x => x.AlbumGenres) .Include(x => x.ArtistGenres) .SingleOrDefaultAsync(x => x.Name == genre); _context.RemoveRange(dbGenre.ArtistGenres); _context.RemoveRange(dbGenre.AlbumGenres); _context.Remove(dbGenre); await _context.SaveChangesAsync(); }