예제 #1
0
파일: update.php 프로젝트: Trideon/gigolo
    header('HTTP/1.1 403 Forbidden', true, 403);
    print json_encode(array('message' => "invalid userId"));
    return;
}
$user_session = new UserSession($user->Id());
// load resource by contact_info or rid
$resourceRepository = new ResourceRepository();
$contact_info = trim($_REQUEST['contact_info']);
$rid = trim($_REQUEST['rid']);
if ($contact_info && $rid) {
    header('HTTP/1.1 406 Not Acceptable', true, 406);
    print json_encode(array('message' => "You must not set both contact_info and rid"));
    return;
}
if ($contact_info) {
    $resource = $resourceRepository->LoadByContactInfo($contact_info);
} elseif ($rid) {
    $resource = $resourceRepository->LoadByPublicId($rid);
}
$updateAction = ReservationAction::Update;
$persistenceFactory = new ReservationPersistenceFactory();
$persistenceService = $persistenceFactory->Create($updateAction);
$handler = ReservationHandler::Create($updateAction, $persistenceService, ServiceLocator::GetServer()->GetUserSession());
$reservationRepository = new ReservationRepository();
$series = $reservationRepository->LoadByReferenceNumber($params['rn']);
if (!$series) {
    header('HTTP/1.1 404 Not Found', true, 404);
    $response = array('reference_number' => $rn, 'message' => 'Reservation could not be found');
    print json_encode($response);
    return;
}