From 23758a1e9e06c0aa6d67a5ad22a61b97bd2f017a Mon Sep 17 00:00:00 2001 From: hardcodder Date: Fri, 16 Apr 2021 10:37:06 +0530 Subject: [PATCH] Added get single course routes --- controllers/course.js | 39 ++++++++++++++++++++++++++++++++++++++- routes/course.js | 7 ++++++- 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/controllers/course.js b/controllers/course.js index ad37075..626e11f 100644 --- a/controllers/course.js +++ b/controllers/course.js @@ -109,4 +109,41 @@ module.exports.getMeetSchedule = async (req , res , next) => { error : "error" }) } -} \ No newline at end of file +} + +module.exports.getSingleParCourse = async (req , res , next) => { + try{ + const parCourseId = req.body.parCourseId ; + console.log(parCourseId) ; + const course = await Course.findById(parCourseId).populate("types.tier1").populate("types.tier2").populate("types.tier3") ; + + res.json({ + course : course + }) + } + catch(err) + { + res.json({ + error : "error" + }) + } +} + +module.exports.getTierCourse = async (req , res , next) => { + try{ + //we need courseTypeId as input + const courseId = req.body.courseId ; + + const course = await CourseType.findById(courseId).populate("course") ; + res.json({ + course : course + }) + + } + catch(err) + { + res.json({ + error : "error" + }) + } +} \ No newline at end of file diff --git a/routes/course.js b/routes/course.js index 0a0dbca..afb025b 100644 --- a/routes/course.js +++ b/routes/course.js @@ -9,7 +9,12 @@ const router = express.Router() ; router.post('/addCourse' ,isAuth , isAdmin , courseController.postAddCourse) ; router.get('/getAllCourses' , courseController.getAllCourses) ; - +//NOTE +//It is a post request +router.post('/getSingleParCourse' , courseController.getSingleParCourse) ; +//NOTE +//It is a post request +router.post('/getTierCourse' , courseController.getTierCourse) ; //NOTE //It is a post request router.post('/getMeetSchedule' ,isAuth , courseController.getMeetSchedule) ;