public async Task<IHttpActionResult> PutPart(int id, Part part) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != part.Id) { return BadRequest(); } db.Entry(part).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PartExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> PostPart(Part part) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Parts.Add(part); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = part.Id }, part); }