public async Task <IHttpActionResult> PutAdministrativeBody(int id, AdministrativeBody administrativeBody) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != administrativeBody.Id) { return(BadRequest()); } db.Entry(administrativeBody).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AdministrativeBodyExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> GetAdministrativeBody(int id) { AdministrativeBody administrativeBody = await db.AdministrativeBodies.FindAsync(id); if (administrativeBody == null) { return(NotFound()); } return(Ok(administrativeBody)); }
public async Task <IHttpActionResult> PostAdministrativeBody(AdministrativeBody administrativeBody) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.AdministrativeBodies.Add(administrativeBody); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = administrativeBody.Id }, administrativeBody)); }
public async Task <IHttpActionResult> DeleteAdministrativeBody(int id) { AdministrativeBody administrativeBody = await db.AdministrativeBodies.FindAsync(id); if (administrativeBody == null) { return(NotFound()); } db.AdministrativeBodies.Remove(administrativeBody); await db.SaveChangesAsync(); return(Ok(administrativeBody)); }