public async Task <IHttpActionResult> PutRaza(int id, RazaPOCO razaParametro) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != razaParametro.Id) { return(BadRequest()); } db.Entry(razaParametro.toDb()).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RazaExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> PostRaza(RazaPOCO razaParametro) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var raza = db.Raza.Add(razaParametro.toDb()); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = raza.Id }, new RazaPOCO(raza))); }