Example #1
0
 /**
  * test updating a rating that doesn't exist
  *
  * @expectedException InvalidArgumentException
  */
 public function testUpdateInvalidRating()
 {
     // create a rating then try and insert it for the fail.
     $rating = new Rating($this->trail->getTrailId(), $this->user->getUserId(), $this->INVALID_RATINGVALUE1);
     $rating->update($this->getPDO());
 }
Example #2
0
$database = new Database();
$db = $database->getConnection();
$originalOption = new Rating($db);
if (isset($_GET['id'])) {
    $id = $_GET['id'];
    $originalOption->Id = $id;
    $originalOption->selectById();
}
if (isset($_POST['update'])) {
    $updatedOption = new Rating($db);
    $updatedOption->Id = $_POST['id'];
    $updatedOption->Rating = $_POST['rating'];
    $updatedOption->Comment = $_POST['comment'];
    $updatedOption->Guest_Id = $_POST['guestid'];
    $updatedOption->MenuOption_Id = $_POST['menuitemid'];
    if ($updatedOption->update() == true) {
        if ($_SESSION['accesslevel'] == 1) {
            header("location:comments.php");
        } else {
            header("location:guest.php");
        }
    } else {
        if ($_SESSION['accesslevel'] == 1) {
            echo "<script>alert('There was an error updating this item');window.location = 'comments.php' </script>";
        } else {
            echo "<script>alert('There was an error updating this item');window.location = 'guest.php' </script>";
        }
    }
}
if (isset($_POST['delete'])) {
    $updatedOption = new Rating($db);
Example #3
0
    $ratingDAO = new Rating();
    $result = $ratingDAO->get();
    echo json_encode($result);
});
$app->post('/rating', function () {
    $request = \Slim\Slim::getInstance()->request();
    $rating = json_decode($request->getBody());
    $ratingDAO = new Rating();
    $ratingDAO->insert($rating);
    echo '{"result":"ok"}';
});
$app->put('/rating', function () {
    $request = \Slim\Slim::getInstance()->request();
    $rating = json_decode($request->getBody());
    $ratingDAO = new Rating();
    $ratingDAO->update($rating);
    echo '{"result":"ok"}';
});
$app->delete('/rating', function () {
    $request = \Slim\Slim::getInstance()->request();
    $rating = json_decode($request->getBody());
    $ratingDAO = new Rating();
    $ratingDAO->delete($rating);
    echo '{"result":"ok"}';
});
$app->get('/state', function () {
    $stateDAO = new State();
    $result = $stateDAO->get();
    echo json_encode($result);
});
$app->post('/state', function () {