File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change 55 getAttendances ,
66} from "#services/attendance" ;
77import { logger } from "#util" ;
8+ import { isEntityIdValid } from "#middleware/entityIdValidation" ;
9+ import Student from "#models/attendance" ;
10+ import Course from "#models/course" ;
811
912async function addAttendance ( req , res ) {
1013 const {
@@ -15,8 +18,15 @@ async function addAttendance(req, res) {
1518 cumulativeAttended,
1619 cumulativeOccured,
1720 } = req . body ;
21+ const isStudentValid = await isEntityIdValid ( student , Student ) ;
22+ const isCourseValid = await isEntityIdValid ( course , Course ) ;
1823 try {
1924 // eslint-disable-next-line max-len
25+ if ( ! isStudentValid || ! isCourseValid ) {
26+ res . status ( 400 ) . json ( {
27+ error : "Invalid Id" ,
28+ } ) ;
29+ }
2030 const attendance = await addNewAttendance (
2131 student ,
2232 course ,
You can’t perform that action at this time.
0 commit comments