public async Task <IHttpActionResult> PostVeterinario(VeterinarioPOCO veterinarioParametro) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var veterinario = db.Veterinario.Add(veterinarioParametro.toDb()); try { await db.SaveChangesAsync(); } catch (DbUpdateException) { if (VeterinarioExists(veterinario.veterinarioId)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = veterinario.veterinarioId }, new VeterinarioPOCO(veterinario))); }
public async Task <IHttpActionResult> PutVeterinario(int id, VeterinarioPOCO veterinarioParametro) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != veterinarioParametro.veterinarioId) { return(BadRequest()); } db.Entry(veterinarioParametro.toDb()).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!VeterinarioExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }