public IHttpActionResult PutAge(int id, Age age) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != age.AgeId) { return BadRequest(); } db.Entry(age).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!AgeExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostAge(Age age) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Ages.Add(age); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = age.AgeId }, age); }