Skip to content

Commit

Permalink
Merge pull request #237 from nus-mtp/#173_Establish_Router
Browse files Browse the repository at this point in the history
#173 establish router
  • Loading branch information
Muhammad-Adam authored Mar 28, 2017
2 parents 2e3ace0 + cda5a6e commit d44d01d
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions server/routes/attendance.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,28 @@ router.get('/get/oneUserAttendance/:email/:id', (req = {}, res, next) => {
}
});

// Get all the Attendances of a specified User
router.get('/get/oneUserAttendances/:email', (req = {}, res, next) => {
if (req.params && req.params.email) {
Attendance.setDBConnection(req.app.locals.db);
Attendance.searchAttendancesByUser(req.params.email, (err, attendances) => {
if (err) {
res.status(500).json('Unable to fetch data!');
next();
} else if (attendances) {
res.status(200).json(attendances.map(attendance => extractAttendanceInfo(attendance)));
next();
} else {
res.status(204).json('No Attendances found!');
next();
}
});
} else {
res.status(400).json('Bad Request!');
next();
}
});

// Get all the Events and Exhibitions that a User is participating in / has participated in
router.get('/get/oneUserEventsAndExhibitions/:email', (req = {}, res, next) => {
if (req.params && req.params.email) {
Expand Down

0 comments on commit d44d01d

Please sign in to comment.