[add] Delete employee

This commit is contained in:
Jose Pabl Domingo Aramburo Sanchez 2018-08-06 03:33:18 -06:00
parent 57ee1fbd72
commit ba307555f0
2 changed files with 24 additions and 0 deletions

View File

@ -387,5 +387,22 @@ class EmployeeApplication{
return $response; return $response;
} }
function disableEmployeeRecord($idEmployee){
try {
$stmt = $this->pdo->prepare("UPDATE employees
SET
status = 'INACTIVE'
WHERE
id = :idEmployee");
$this->pdo->beginTransaction();
$stmt->execute(array(':idEmployee' => $idEmployee));
$this->pdo->commit();
$stmt = null;
} catch( PDOExecption $e ) {
$this->pdo->rollback();
}
}
} }
?> ?>

View File

@ -57,6 +57,13 @@ $app->put('/api/employee', function ($request, $response) {
->write(json_encode($this->employeeApplication->updateEmployeeData($requestData))); ->write(json_encode($this->employeeApplication->updateEmployeeData($requestData)));
}); });
$app->DELETE('/api/employee/{idEmployee}', function (Request $request, Response $response, array $args) {
$idEmployee = $args['idEmployee'];
return $response->withStatus(200)
->withHeader('Content-Type', 'application/json')
->write(json_encode($this->employeeApplication->disableEmployeeRecord($idEmployee)));
});
$app->get('/api/employee/type/{code}', function (Request $request, Response $response, array $args) { $app->get('/api/employee/type/{code}', function (Request $request, Response $response, array $args) {
$code = $args['code']; $code = $args['code'];