forked from CSI-KJSCE/appointment_to_examiner
academicYear logic
This commit is contained in:
@@ -14,7 +14,7 @@ router.post("/", async (req, res) => {
|
||||
|
||||
const savedAppointments = [];
|
||||
for (const appointment of appointments) {
|
||||
const { facultyId, courseId, tasks, examPeriod } = appointment;
|
||||
const { facultyId, courseId, tasks, examPeriod, academicYear } = appointment;
|
||||
|
||||
if (
|
||||
!facultyId ||
|
||||
@@ -43,6 +43,7 @@ router.post("/", async (req, res) => {
|
||||
courseName: course.name,
|
||||
task,
|
||||
examPeriod,
|
||||
academicYear,
|
||||
});
|
||||
const savedAppointment = await newAppointment.save();
|
||||
savedAppointments.push(savedAppointment);
|
||||
@@ -58,8 +59,9 @@ router.post("/", async (req, res) => {
|
||||
|
||||
// Get all appointments
|
||||
router.get("/", async (req, res) => {
|
||||
const { academicYear } = req.query;
|
||||
try {
|
||||
const appointments = await Appointment.find();
|
||||
const appointments = await Appointment.find({ academicYear });
|
||||
res.json(appointments);
|
||||
} catch (error) {
|
||||
console.error("Error fetching appointments:", error);
|
||||
|
||||
Reference in New Issue
Block a user