[add] Delete employee
This commit is contained in:
parent
57ee1fbd72
commit
ba307555f0
@ -387,5 +387,22 @@ class EmployeeApplication{
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
@ -57,6 +57,13 @@ $app->put('/api/employee', function ($request, $response) {
|
||||
->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) {
|
||||
$code = $args['code'];
|
||||
|
Loading…
Reference in New Issue
Block a user