public IHttpActionResult PutMicroRegiao(int id, MicroRegiao microRegiao) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != microRegiao.cd_microregiao) { return BadRequest(); } db.Entry(microRegiao).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!MicroRegiaoExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostMicroRegiao(MicroRegiao microRegiao) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.MicroRegiao.Add(microRegiao); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = microRegiao.cd_microregiao }, microRegiao); }