import { Body, Controller, Delete, Get, Param, ParseIntPipe, Patch, Post, Res, UseGuards, } from '@nestjs/common'; import { Response } from 'express'; import { InjectRepository } from '@nestjs/typeorm'; import { EventoParticipante } from 'src/evento-participante/evento-participante/eventoParticipante.entity'; import { Repository } from 'typeorm'; import { actualizarEventoDto } from './dto/actualizarEvento.dto'; import { crearEventoDto } from './dto/crearEvento.dto'; import { Evento } from './evento.entity'; import { EventosService } from './eventos.service'; import { AuthGuard } from '@nestjs/passport'; @Controller('eventos') export class EventosController { constructor(private readonly eventoService: EventosService) {} @Get() getEventos(): Promise { return this.eventoService.getEventos(); } @Get('disponibles') getEventosDisponibles() { return this.eventoService.getEventosDisponibles(); } @Get(':id') getEventosPorId(@Param('id', ParseIntPipe) id: number): Promise { return this.eventoService.getEventosPorId(id); } @UseGuards(AuthGuard('jwt')) @Post() postEvento(@Body() nuevoEvento: crearEventoDto) { return this.eventoService.postEvento(nuevoEvento); } @UseGuards(AuthGuard('jwt')) @Patch(':id') patchEvento( @Param('id', ParseIntPipe) id: number, @Body() actualizacion: actualizarEventoDto, ) { return this.eventoService.updateEvento(id, actualizacion); } @UseGuards(AuthGuard('jwt')) @Delete(':id') deleteEvento(@Param('id', ParseIntPipe) id: number) { return this.eventoService.deleteEventoParticipante(id); } @Get(':id/cupos') async getCupos(@Param('id', ParseIntPipe) id: number) { return this.eventoService.getCupos(id); } @UseGuards(AuthGuard('jwt')) @Get(':id/participante') async getParticipnates(@Param('id', ParseIntPipe) id: number) { return this.eventoService.getParticipantes(id); } @UseGuards(AuthGuard('jwt')) @Get(':id/exportExcel') async exportarExcel( @Param('id', ParseIntPipe) id: number, @Res() res: Response, ) { this.eventoService.exportarParticipantes(id, res); } @Post('disponibles/pendientesDconstancia') getEventosDisponiblesPendientes() { return this.eventoService.geteventosDisponiblesMasDosDias(); } }