public IHttpActionResult PutPerson(int id, Person person) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != person.Id) { return BadRequest(); } db.Entry(person).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!PersonExists(id)) { return NotFound(); } else { throw; } } return Ok(person); }
public IHttpActionResult PostPerson(Person person) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.People.Add(person); db.SaveChanges(); return Ok(person); }