userCourse bulk controller
Yash
plain_text
a year ago
948 B
11
Indexable
@Patch('bulk-update')
async bulkUpdate(@Body() bulkUpdateDto: BulkUpdateUserCourseDto) {
const { userCourses, batch } = bulkUpdateDto;
console.log("bulk update happening")
try {
if (batch) {
const batchStrengthDetails = await this.userCourseService.batchLimitStrengthCheck(batch);
const totalNewStudents = bulkUpdateDto.userCourses.length;
const studentBatch = isNaN(batchStrengthDetails.studentBatch) ? 0 : batchStrengthDetails.studentBatch;
if (studentBatch + totalNewStudents > batchStrengthDetails.batchStrength) {
throw new NotAcceptableException("Batch Limit Exceeded for bulk update");
}
}
return await this.userCourseService.bulkUpdate(bulkUpdateDto);
} catch (error) {
throw new BadRequestException(error.message);
}
}Editor is loading...
Leave a Comment