public async Task <IActionResult> PutAlbum([FromRoute] int id, [FromBody] Album album) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != album.AlbumId) { return(BadRequest()); } _context.Entry(album).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AlbumExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> Post([FromBody] Album album) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Albums.Add(album); await db.SaveChangesAsync(); return(CreatedAtAction("Post", new { id = album.AlbumId }, album)); }