예제 #1
0
        $response->json(Result::success('RentDemand Updated.'));
    } elseif ($result === 0) {
        $response->json(Result::success('RentDemand not Updated.'));
    } else {
        $response->json(Result::error('RentDemand not found'));
    }
});
$this->respond(['GET', 'POST'], '/match-mod/get/assets', function ($request, $response, $service, $app) {
    $id = $request->param('id');
    $result = Assets::getRentDemandMatchingAssets($id);
    $response->json(Result::success('', $result));
});
$this->respond(['GET', 'POST'], '/match-mod/match', function ($request, $response, $service, $app) {
    $rentDemandID = $request->param('rentDemandID');
    $assetID = $request->param('assetID');
    $id = RentProcesses::matchRentDemandAndAsset($rentDemandID, $assetID);
    if ($id > 0) {
        $response->json(Result::success('Matched.', ['rentProcessID' => $id]));
    } else {
        $response->json(Result::error('Error trying to match'));
    }
});
$this->respond(['GET', 'POST'], '/delete/[:id]', function ($request, $response, $service, $app) {
    $id = $request->param('id');
    $rentDemandResult = RentDemands::deleteRentDemand($id);
    RentProcesses::deleteRentDemandProcesses($id);
    if ($rentDemandResult > 0) {
        $response->json(Result::success('Demand Deleted.'));
    } else {
        $response->json(Result::error('Demand not Deleted'));
    }