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) ;