forked from pedrofaria09/LTW_Projeto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreview_actions.php
40 lines (30 loc) · 1 KB
/
review_actions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
include_once('sql/connection.php');
include_once('sql/restaurant.php');
include_once('sql/utilities.php');
function actionInsertReview($obj){
$review = insertReview($obj->restaurantId, $obj->userId, $obj->reviewText, $obj->reviewDate, $obj->ratingValue, $obj->priceRange);
if ( $review < 0)
return generateResponse('algo aconteceu!!', 'denied');
return generateResponse('Added review with success!!', 'successfully');
}
function actionInsertComment($obj){
$comment = insertComment($obj->userId, $obj->reviewId, $obj->commentDate, $obj->commentText);
if ($comment < 0)
return generateResponse('algo aconteceu!!', 'denied');
return generateResponse('Added comment with success!!', 'successfully');
}
$data = file_get_contents('php://input');
if (isset($data)) {
$obj = json_decode($data);
switch($obj->type) {
case 'addReview':
$result = actionInsertReview($obj);
break;
case 'addComment':
$result = actionInsertComment($obj);
break;
}
}
echo json_encode($result);
?>