diff --git a/server/controllers/Course.js b/server/controllers/Course.js index 78fa21b..dcba816 100644 --- a/server/controllers/Course.js +++ b/server/controllers/Course.js @@ -425,8 +425,10 @@ exports.getInstructorCourses = async (req, res) => { // Delete the Course exports.deleteCourse = async (req, res) => { try { - const { categoryId, courseId } = req.body - + const {courseId } = req.body + + console.log("Course Id -> ", courseId) + // Find the course const course = await Course.findById(courseId) console.log("Course -> ", course) @@ -442,7 +444,20 @@ exports.deleteCourse = async (req, res) => { $pull: { courses: courseId }, }) } - + + //delete the entry of this course from the course list of instructor + const courseInstructorId = course.instructor + const updatedCourseList = await User.findByIdAndUpdate(courseInstructorId, + { + $pull: { + courses: courseId + } + }, + {new: true}) + .populate("courses") + .exec() + console.log("Updated courses list -> ", updatedCourseList) + // Delete sections and sub-sections const courseSections = course.courseContent console.log("Course Section -> ", courseSections) @@ -464,14 +479,12 @@ exports.deleteCourse = async (req, res) => { // Delete the section await Section.findByIdAndDelete(sectionId) } - - // Delete the course - await Course.findByIdAndDelete(courseId) //TODO: Update the category schema..i.e.. //we have to delete the course from the courses array of category model + const categoryId = course.category const updatedCategory = await Category.findByIdAndUpdate( - {_id: categoryId}, + categoryId, { $pull: { courses: courseId, @@ -480,6 +493,12 @@ exports.deleteCourse = async (req, res) => { {new: true}) .populate("courses") .exec() + + console.log("Category Id -> ", categoryId) + console.log("Upated category details -> ", updatedCategory) + + // Delete the course + await Course.findByIdAndDelete(courseId) return res.status(200).json({ success: true, diff --git a/server/mail/templates/contactFormRes.js b/server/mail/templates/contactFormRes.js index 5f6f8e2..0479fe8 100644 --- a/server/mail/templates/contactFormRes.js +++ b/server/mail/templates/contactFormRes.js @@ -74,8 +74,7 @@ exports.contactUsEmail = (
Dear ${firstname} ${lastname},
diff --git a/server/mail/templates/courseEnrollmentEmail.js b/server/mail/templates/courseEnrollmentEmail.js index fa88264..3549858 100644 --- a/server/mail/templates/courseEnrollmentEmail.js +++ b/server/mail/templates/courseEnrollmentEmail.js @@ -67,8 +67,7 @@ exports.courseEnrollmentEmail = (courseName, name) => {Dear ${name},
diff --git a/server/mail/templates/emailVerificationTemplate.js b/server/mail/templates/emailVerificationTemplate.js index ce825cd..777be84 100644 --- a/server/mail/templates/emailVerificationTemplate.js +++ b/server/mail/templates/emailVerificationTemplate.js @@ -66,8 +66,7 @@ const otpTemplate = (otp) => {Dear User,
diff --git a/server/mail/templates/passwordUpdate.js b/server/mail/templates/passwordUpdate.js index 85dbf8d..36e5d16 100644 --- a/server/mail/templates/passwordUpdate.js +++ b/server/mail/templates/passwordUpdate.js @@ -55,8 +55,7 @@ exports.passwordUpdated = (email, name) => {Hey ${name},
diff --git a/server/mail/templates/paymentSuccessEmail.js b/server/mail/templates/paymentSuccessEmail.js index 3b0b43d..304d52a 100644 --- a/server/mail/templates/paymentSuccessEmail.js +++ b/server/mail/templates/paymentSuccessEmail.js @@ -67,8 +67,7 @@ exports.paymentSuccessEmail = (name, amount, orderId, paymentId) => {Dear ${name},
@@ -77,7 +76,7 @@ exports.paymentSuccessEmail = (name, amount, orderId, paymentId) => {Your Order ID is ${orderId}