public async Task<IHttpActionResult> PutAlbum(int id, Album album) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != album.Id) { return BadRequest(); } db.Entry(album).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AlbumExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> PostAlbum(Album album) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Albums.Add(album); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = album.Id }, album); }