public async Task <IHttpActionResult> PutLocal(int id, LocalPOCO localParametro) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != localParametro.Id) { return(BadRequest()); } db.Entry(localParametro.toDb()).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LocalExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> PostLocal(LocalPOCO localParametro) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var loc = db.Local.Add(localParametro.toDb()); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = loc.Id }, new LocalPOCO(loc))); }