public async Task <IHttpActionResult> PutPersona(int id, PersonaPOCO personaParametro) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != personaParametro.Id) { return(BadRequest()); } db.Entry(personaParametro.toDb()).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PersonaExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> PostPersona(PersonaPOCO personaParametro) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var persona = db.Persona.Add(personaParametro.toDb()); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = persona.Id }, new PersonaPOCO(persona))); }