Skip to content

Commit

Permalink
Update attendance.js
Browse files Browse the repository at this point in the history
  • Loading branch information
deepti-50 authored Dec 19, 2023
1 parent 4f171f8 commit 4b7eb45
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions controller/attendance.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import {
getAttendances,
} from "#services/attendance";
import { logger } from "#util";
import { isEntityIdValid } from "#middleware/entityIdValidation";
import Student from "#models/attendance";
import Course from "#models/course";

async function addAttendance(req, res) {
const {
Expand All @@ -15,8 +18,15 @@ async function addAttendance(req, res) {
cumulativeAttended,
cumulativeOccured,
} = req.body;
const isStudentValid = await isEntityIdValid(student, Student);
const isCourseValid = await isEntityIdValid(course, Course);
try {
// eslint-disable-next-line max-len
if (!isStudentValid || !isCourseValid) {
res.status(400).json({
error: "Invalid Id",
});
}
const attendance = await addNewAttendance(
student,
course,
Expand Down

0 comments on commit 4b7eb45

Please sign in to comment.