Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Post()
- @UseGuards(JwtAuthGuard)
- @ApiBearerAuth()
- @UsePipes(new ValidationPipe({ transform: true }))
- @ApiBody({ type: TicketDto })
- @ApiCreatedResponse({description: 'Ticket created'})
- @ApiOperation({ summary: 'Insert ticket' })
- @ApiResponse({ status: 201, description: 'The ticket has been successfully inserted.'})
- @ApiResponse({ status: 403, description: 'Forbidden.' })
- @ApiUnauthorizedResponse({description: 'Not authenticated or not admin on organization'})
- async insert(
- @Body() entity: TicketPaymentsDto,
- @Request() req,
- ): Promise<TicketEntity | InternalServerErrorException | UnauthorizedException | undefined> {
- const ticket: TicketEntity | InternalServerErrorException | UnauthorizedException | undefined =
- await this.entitiesService.insert(entity, req);
- if (ticket instanceof TicketEntity) {
- entity.payments[0].ticketId = ticket.id;
- const payments = await this.paymentsService.insert(entity.payments[0]);
- if (payments) {
- return await this.entitiesService.findOne(ticket.id, req);
- } else {
- return new InternalServerErrorException('Insert payment failed');
- }
- } else {
- return new InternalServerErrorException('Insert failed');
- }
- }
Add Comment
Please, Sign In to add comment