public async Task <IHttpActionResult> PutEmpleado(int id, BOL.Empleado empleado) { if (id != empleado.Id) { return(BadRequest()); } db.Entry(empleado).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EmpleadoExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> PostEmpleado(BOL.Empleado empleado) { db.Empleado.Add(empleado); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = empleado.Id }, empleado)); }
public async Task <IHttpActionResult> GetEmpleado(int id) { BOL.Empleado empleado = await db.Empleado.FindAsync(id); if (empleado == null) { return(NotFound()); } return(Ok(empleado)); }
public async Task <IHttpActionResult> DeleteEmpleado(int id) { BOL.Empleado empleado = await db.Empleado.FindAsync(id); if (empleado == null) { return(NotFound()); } db.Empleado.Remove(empleado); await db.SaveChangesAsync(); return(Ok(empleado)); }