$result = array("message" => $service->findBy($usuario, $password));
        $app->response->body(json_encode($result));
    } catch (UserNotFoundExeption $ue) {
        $app->response()->setStatus(200);
        $result = array("message" => $service->login($usuario, $password));
        $app->response->body(json_encode($result));
    } catch (Exception $e) {
        $app->response()->setStatus(500);
        $app->response->body(json_encode($e->getMessage()));
    }
});
$app->delete("/usuario/", function () use($app) {
    $usuario = $app->request->delete('usuario');
    try {
        $service = new UserService();
        $result = array("message" => $service->delete($usuario));
        $app->response->body(json_encode($result));
    } catch (UserNotFoundExeption $ue) {
        $app->response()->setStatus(200);
        $result = array("message" => $service->delete($usuario));
        $app->response->body(json_encode($result));
    } catch (Exception $e) {
        $app->response()->setStatus(500);
        $app->response->body(json_encode($e->getMessage()));
    }
});
$app->get("/usuarios", function () use($app) {
    try {
        $service = new UserService();
        $result = array("message" => $service->getAll());
        $app->response->body(json_encode($result));
Example #2
0
 public function delete()
 {
     $userIds = $this->input->post('userIds');
     $userService = new UserService();
     $userService->delete($userIds);
 }