public IHttpActionResult PutCarType(int id, CarType carType) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != carType.Id) { return BadRequest(); } try { rep.Update(id, carType); } catch (DbUpdateConcurrencyException) { if (!rep.CarTypeExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostCarType(CarType carType) { if (!ModelState.IsValid) { return BadRequest(ModelState); } rep.Add(carType); return CreatedAtRoute("DefaultApi", new { id = carType.Id }, carType); }