public IHttpActionResult PostStates(States states) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.States.Add(states); try { db.SaveChanges(); } catch (DbUpdateException) { if (StatesExists(states.StateId)) { return Conflict(); } else { throw; } } return CreatedAtRoute("DefaultApi", new { id = states.StateId }, states); }
public IHttpActionResult PutStates(string id, States states) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != states.StateId) { return BadRequest(); } db.Entry(states).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!StatesExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }