// PUT api/Car/5 public IHttpActionResult Putcar(int id, car car) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != car.id) { return BadRequest(); } db.Entry(car).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!carExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult Postcar(car car) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.cars.Add(car); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = car.id }, car); }