public IHttpActionResult PutArtist(int id, Artist artist) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != artist.ArtistId) { return BadRequest(); } db.Entry(artist).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ArtistExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostArtist(Artist artist) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.MyArtists.Add(artist); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = artist.ArtistId }, artist); }