Skip to content

Commit

Permalink
Merge pull request #465 from tcet-opensource/deepti-50-patch-1
Browse files Browse the repository at this point in the history
[ADDED] added validation for attedance
  • Loading branch information
Aastha-S-Rai authored Dec 27, 2023
2 parents 8eed790 + 4b7eb45 commit e20ba34
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 e20ba34

Please sign in to comment.