Skip to content

Commit 71fbe9e

Browse files
author
KushanChamindu
committed
Create mysql trigger for book_fight and update book_fight post(/:id)
1 parent 868f632 commit 71fbe9e

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

routes/book_fight/index.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ router.get('/:id', (req, res) => {
7373
let seat_id=req.body.seat_id;
7474
let user_id=req.body.user_id;
7575
let json_response = json_response_model(); //Json response object created
76-
console.log(id,schedule_id,seat_id,user_id);
76+
// console.log(id,schedule_id,seat_id,user_id);
7777
connection.beginTransaction((error) => {
7878
if(error){
7979
json_response['success'] = false;
@@ -87,9 +87,16 @@ router.get('/:id', (req, res) => {
8787
// console.log(todaydate);
8888
// let error_code=200;
8989
if(error){
90-
json_response['success'] = false;
91-
json_response['message'] = error;
92-
res.status(501).json(json_response);
90+
if(error.sqlState == 45000){
91+
error['sqlMessage']="Seat already booked"
92+
json_response['success'] = false;
93+
json_response['message'] = error['sqlMessage'];
94+
res.status(400).json(json_response);
95+
}else{
96+
json_response['success'] = false;
97+
json_response['message'] = error;
98+
res.status(501).json(json_response);
99+
}
93100
}else{
94101
let price_query="SELECT get_Total_price_with_discount("+user_id+","+seat_id+")"
95102
connection.query(price_query,(error,result)=>{

0 commit comments

Comments
 (0)