-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6b1e848
commit 7b1c670
Showing
31 changed files
with
1,400 additions
and
1,425 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
# parkify | ||
|
||
Parking Web Application. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,21 @@ | ||
const cloudinary = require('cloudinary').v2; | ||
const { CloudinaryStorage } = require('multer-storage-cloudinary'); | ||
const cloudinary = require("cloudinary").v2; | ||
const { CloudinaryStorage } = require("multer-storage-cloudinary"); | ||
|
||
cloudinary.config({ | ||
cloud_name: process.env.CLOUDINARY_CLOUD_NAME, | ||
api_key: process.env.CLOUDINARY_KEY, | ||
api_secret: process.env.CLOUDINARY_SECRET, | ||
cloud_name: process.env.CLOUDINARY_CLOUD_NAME, | ||
api_key: process.env.CLOUDINARY_KEY, | ||
api_secret: process.env.CLOUDINARY_SECRET, | ||
}); | ||
|
||
const storage = new CloudinaryStorage({ | ||
cloudinary, | ||
params: { | ||
folder: 'Parkify', | ||
allowedFormats: ['jpeg', 'png', 'jpg'], | ||
}, | ||
cloudinary, | ||
params: { | ||
folder: "Parkify", | ||
allowedFormats: ["jpeg", "png", "jpg"], | ||
}, | ||
}); | ||
|
||
module.exports = { | ||
cloudinary, | ||
storage, | ||
cloudinary, | ||
storage, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,89 +1,84 @@ | ||
const bookingService = require('../services/booking.service'); | ||
const slotService=require('../services/slot.service'); | ||
const garageService=require('../services/garage.service'); | ||
const bookingService = require("../services/booking.service"); | ||
const slotService = require("../services/slot.service"); | ||
const garageService = require("../services/garage.service"); | ||
|
||
const renderNewBooking = async(req, res) => { | ||
var slot_id=req.params.id; | ||
var slot=await slotService.FindSlot(slot_id); | ||
if(slot===null) | ||
{ | ||
req.flash('err','Slot doesnt exist'); | ||
res.redirect('/garage'); | ||
} | ||
else | ||
{ | ||
var garage=await garageService.FindGarage(slot.garage_id); | ||
if(!garage) | ||
{ | ||
req.flash('err','Garage doesnt exist for the slot.'); | ||
res.redirect('/garage'); | ||
} | ||
else{ | ||
res.render('bookings/newbooking',{userid:req.body.user_id,slot:slot,body: req.body,garage:garage}); | ||
} | ||
const renderNewBooking = async (req, res) => { | ||
var slot_id = req.params.id; | ||
var slot = await slotService.FindSlot(slot_id); | ||
if (slot === null) { | ||
req.flash("err", "Slot doesnt exist"); | ||
res.redirect("/garage"); | ||
} else { | ||
var garage = await garageService.FindGarage(slot.garage_id); | ||
if (!garage) { | ||
req.flash("err", "Garage doesnt exist for the slot."); | ||
res.redirect("/garage"); | ||
} else { | ||
res.render("bookings/newbooking", { | ||
userid: req.body.user_id, | ||
slot: slot, | ||
body: req.body, | ||
garage: garage, | ||
}); | ||
} | ||
} | ||
}; | ||
|
||
const newBooking=async(req,res)=>{ | ||
req.body.start_time=(new Date(req.body.start_datetime).getTime())/1000; | ||
req.body.end_time=(new Date(req.body.end_datetime).getTime())/1000; | ||
req.body.amount=(await bookingService.apiMoney(req.body.slot_id))*((req.body.end_time-req.body.start_time)/60); | ||
try { | ||
const result = await bookingService.NewBooking(req.body); | ||
req.flash('success','Booking Created Successfully'); | ||
res.redirect('/users/dashboard'); | ||
} catch (err) { | ||
req.flash('err',err); | ||
res.redirect('/booking/new/'+req.body.slot_id); | ||
} | ||
} | ||
const newBooking = async (req, res) => { | ||
req.body.start_time = new Date(req.body.start_datetime).getTime() / 1000; | ||
req.body.end_time = new Date(req.body.end_datetime).getTime() / 1000; | ||
req.body.amount = | ||
(await bookingService.apiMoney(req.body.slot_id)) * | ||
((req.body.end_time - req.body.start_time) / 60); | ||
try { | ||
const result = await bookingService.NewBooking(req.body); | ||
req.flash("success", "Booking Created Successfully"); | ||
res.redirect("/users/dashboard"); | ||
} catch (err) { | ||
req.flash("err", err); | ||
res.redirect("/booking/new/" + req.body.slot_id); | ||
} | ||
}; | ||
|
||
const renderBooking=async(req,res)=> | ||
{ | ||
var booking_id = req.params.id; | ||
const booking = await bookingService.FindBooking(booking_id); | ||
if (!booking) { | ||
req.flash('err','Booking Not Found'); | ||
res.redirect('/users/dashboard'); | ||
} else { | ||
res.send(booking); | ||
} | ||
} | ||
const renderBooking = async (req, res) => { | ||
var booking_id = req.params.id; | ||
const booking = await bookingService.FindBooking(booking_id); | ||
if (!booking) { | ||
req.flash("err", "Booking Not Found"); | ||
res.redirect("/users/dashboard"); | ||
} else { | ||
res.send(booking); | ||
} | ||
}; | ||
|
||
const deleteBooking=async(req,res)=> | ||
{ | ||
var booking_id=req.params.id; | ||
try{ | ||
await bookingService.DeleteBooking(booking_id); | ||
req.flash('success','Booking Deleted Successfully'); | ||
res.redirect('/users/dashboard'); | ||
} | ||
catch(err) | ||
{ | ||
req.flash('err',"Error :"+err); | ||
res.redirect('/users/dashboard'); | ||
} | ||
} | ||
const deleteBooking = async (req, res) => { | ||
var booking_id = req.params.id; | ||
try { | ||
await bookingService.DeleteBooking(booking_id); | ||
req.flash("success", "Booking Deleted Successfully"); | ||
res.redirect("/users/dashboard"); | ||
} catch (err) { | ||
req.flash("err", "Error :" + err); | ||
res.redirect("/users/dashboard"); | ||
} | ||
}; | ||
|
||
const cancelBooking=async(req,res)=> | ||
{ | ||
var id=req.params.id; | ||
try{ | ||
await bookingService.cancelBooking(id); | ||
req.flash('success','Booking cancelled successfully'); | ||
res.redirect('/users/dashboard'); | ||
} | ||
catch(err) | ||
{ | ||
req.flash('err',err); | ||
res.redirect('/users/dashboard'); | ||
} | ||
} | ||
const cancelBooking = async (req, res) => { | ||
var id = req.params.id; | ||
try { | ||
await bookingService.cancelBooking(id); | ||
req.flash("success", "Booking cancelled successfully"); | ||
res.redirect("/users/dashboard"); | ||
} catch (err) { | ||
req.flash("err", err); | ||
res.redirect("/users/dashboard"); | ||
} | ||
}; | ||
|
||
module.exports={ | ||
renderNewBooking, | ||
newBooking, | ||
renderBooking, | ||
deleteBooking, | ||
cancelBooking | ||
}; | ||
module.exports = { | ||
renderNewBooking, | ||
newBooking, | ||
renderBooking, | ||
deleteBooking, | ||
cancelBooking, | ||
}; |
Oops, something went wrong.