| Total Complexity | 2 | 
| Total Lines | 36 | 
| Duplicated Lines | 0 % | 
| Changes | 0 | ||
| 1 | import { | 
            ||
| 18 | |||
| 19 | @Controller('leave-requests') | 
            ||
| 20 | @ApiTags('Human Resource') | 
            ||
| 21 | @ApiBearerAuth()  | 
            ||
| 22 | @UseGuards(AuthGuard('bearer'), RolesGuard) | 
            ||
| 23 | export class UpdateLeaveRequestAction { | 
            ||
| 24 | constructor(  | 
            ||
| 25 |     @Inject('ICommandBus') | 
            ||
| 26 | private readonly commandBus: ICommandBus  | 
            ||
| 27 |   ) { } | 
            ||
| 28 | |||
| 29 |   @Put(':id') | 
            ||
| 30 | @Roles(UserRole.COOPERATOR, UserRole.EMPLOYEE)  | 
            ||
| 31 |   @ApiOperation({ summary: 'Update existing leave request' }) | 
            ||
| 32 | public async index(  | 
            ||
| 33 |     @Param() { id }, | 
            ||
| 34 | @Body() dto: LeaveRequestDTO,  | 
            ||
| 35 |   ) { | 
            ||
| 36 |     const { type, startDate, startsAllDay, endDate, endsAllDay, comment } = dto; | 
            ||
| 37 | |||
| 38 |     try { | 
            ||
| 39 | await this.commandBus.execute(  | 
            ||
| 40 | new UpdateLeaveRequestCommand(  | 
            ||
| 41 | id,  | 
            ||
| 42 | type,  | 
            ||
| 43 | startDate,  | 
            ||
| 44 | startsAllDay,  | 
            ||
| 45 | endDate,  | 
            ||
| 46 | endsAllDay,  | 
            ||
| 47 | comment  | 
            ||
| 48 | )  | 
            ||
| 49 | );  | 
            ||
| 50 | |||
| 51 |       return { id }; | 
            ||
| 52 |     } catch (e) { | 
            ||
| 53 | throw new BadRequestException(e.message);  | 
            ||
| 54 | }  | 
            ||
| 57 |