userCourse bulk controller

 avatar
user_7119000
plain_text
a month ago
948 B
2
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);
        }
    }
Leave a Comment