public async Task <IActionResult> PutArtist(int id, Artist artist) { if (id != artist.ArtistId) { return(BadRequest()); } _context.Entry(artist).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ArtistExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutTrack(int id, Track track) { if (id != track.TrackId) { return(BadRequest()); } _context.Entry(track).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TrackExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutSong(int id, Song song) { if (id != song.SongId) { return(BadRequest()); } _context.Entry(song).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SongExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task Add(TEntity entity) { await db.Set <TEntity>().AddAsync(entity); await db.SaveChangesAsync(); }