public async Task <IHttpActionResult> PutEstudio(int id, EstudioPOCO estudioParametro) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != estudioParametro.Id) { return(BadRequest()); } db.Entry(estudioParametro.toDb()).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EstudioExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> PostEstudio(EstudioPOCO estudioParametro) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var estudio = db.Estudio.Add(estudioParametro.toDb()); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = estudio.Id }, new EstudioPOCO(estudio))); }