public async Task<IHttpActionResult> PutPlano(int id, Plano plano) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != plano.idPlano) { return BadRequest(); } db.Entry(plano).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PlanoExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> PostPlano(Plano plano) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Planoes.Add(plano); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = plano.idPlano }, plano); }