Updating employee data #7

Merged
PootisPenserHere merged 3 commits from updatingEmployeeData into master 2018-08-06 09:35:10 +00:00
2 changed files with 24 additions and 0 deletions
Showing only changes of commit ba307555f0 - Show all commits

View File

@ -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();
}
}
}
?>

View File

@ -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'];