public IHttpActionResult PutEthnicity(int id, Ethnicity ethnicity) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != ethnicity.EthnicityId) { return BadRequest(); } db.Entry(ethnicity).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!EthnicityExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostEthnicity(Ethnicity ethnicity) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Ethnicities.Add(ethnicity); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = ethnicity.EthnicityId }, ethnicity); }