2023-06-26 08:33:18 -06:00
|
|
|
import { Body, Controller, Delete, Get, Param, ParseIntPipe, Patch, Post, Res, UseGuards } from '@nestjs/common';
|
2023-03-17 13:38:37 -06:00
|
|
|
import { Response } from 'express';
|
2023-03-10 09:10:57 -06:00
|
|
|
import { InjectRepository } from '@nestjs/typeorm';
|
|
|
|
|
import { EventoParticipante } from 'src/evento-participante/evento-participante/eventoParticipante.entity';
|
|
|
|
|
import { Repository } from 'typeorm';
|
2023-02-16 16:49:52 -06:00
|
|
|
import { actualizarEventoDto } from './dto/actualizarEvento.dto';
|
|
|
|
|
import { crearEventoDto } from './dto/crearEvento.dto';
|
|
|
|
|
import { Evento } from './evento.entity';
|
|
|
|
|
import { EventosService } from './eventos.service';
|
2023-06-26 08:33:18 -06:00
|
|
|
import { AuthGuard } from '@nestjs/passport';
|
2023-02-16 16:49:52 -06:00
|
|
|
|
|
|
|
|
@Controller('eventos')
|
|
|
|
|
export class EventosController {
|
|
|
|
|
|
|
|
|
|
constructor(private readonly eventoService: EventosService){}
|
|
|
|
|
|
|
|
|
|
@Get()
|
|
|
|
|
getEventos(): Promise<Evento[]>{
|
|
|
|
|
return this.eventoService.getEventos()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Get(':id')
|
|
|
|
|
getEventosPorId(@Param('id', ParseIntPipe)id: number):Promise<Evento>{
|
|
|
|
|
return this.eventoService.getEventosPorId(id)
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-26 08:33:18 -06:00
|
|
|
@UseGuards(AuthGuard('jwt'))
|
2023-02-16 16:49:52 -06:00
|
|
|
@Post()
|
2023-02-27 14:01:13 -06:00
|
|
|
postEvento(@Body() nuevoEvento: crearEventoDto){
|
2023-02-16 16:49:52 -06:00
|
|
|
return this.eventoService.postEvento(nuevoEvento)
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-26 08:33:18 -06:00
|
|
|
@UseGuards(AuthGuard('jwt'))
|
2023-02-16 16:49:52 -06:00
|
|
|
@Patch(':id')
|
|
|
|
|
patchEvento(@Param('id', ParseIntPipe)id:number, @Body() actualizacion: actualizarEventoDto){
|
|
|
|
|
return this.eventoService.updateEvento(id,actualizacion)
|
|
|
|
|
}
|
2023-06-26 08:33:18 -06:00
|
|
|
|
|
|
|
|
@UseGuards(AuthGuard('jwt'))
|
2023-02-16 16:49:52 -06:00
|
|
|
@Delete(':id')
|
|
|
|
|
deleteEvento(@Param('id', ParseIntPipe)id: number){
|
2023-02-27 14:01:13 -06:00
|
|
|
return this.eventoService.deleteEventoParticipante(id)
|
2023-02-16 16:49:52 -06:00
|
|
|
}
|
2023-03-10 09:10:57 -06:00
|
|
|
|
2023-03-14 15:26:00 -06:00
|
|
|
@Get(':id/cupos')
|
2023-03-10 09:10:57 -06:00
|
|
|
async getCupos(@Param('id', ParseIntPipe)id: number){
|
|
|
|
|
return this.eventoService.getCupos(id)
|
|
|
|
|
}
|
2023-03-14 15:26:00 -06:00
|
|
|
|
2023-06-26 08:33:18 -06:00
|
|
|
@UseGuards(AuthGuard('jwt'))
|
2023-03-14 15:26:00 -06:00
|
|
|
@Get(':id/participante')
|
|
|
|
|
async getParticipnates(@Param('id', ParseIntPipe)id:number){
|
|
|
|
|
return this.eventoService.getParticipantes(id)
|
|
|
|
|
}
|
2023-03-17 13:38:37 -06:00
|
|
|
|
2023-06-26 08:33:18 -06:00
|
|
|
@UseGuards(AuthGuard('jwt'))
|
2023-03-17 13:38:37 -06:00
|
|
|
@Get(':id/exportExcel')
|
|
|
|
|
async exportarExcel (@Param('id', ParseIntPipe)id:number ,@Res() res: Response){
|
2023-03-21 14:23:35 -06:00
|
|
|
this.eventoService.exportarParticipantes(id, res)
|
2023-03-17 13:38:37 -06:00
|
|
|
}
|
|
|
|
|
|
2023-03-20 20:00:10 -06:00
|
|
|
@Post('disponibles')
|
|
|
|
|
getEventosDisponibles (){
|
|
|
|
|
return this.eventoService.getEventosDisponibles()
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-24 15:00:03 -06:00
|
|
|
@Post('disponibles/pendientesDconstancia')
|
|
|
|
|
getEventosDisponiblesPendientes(){
|
|
|
|
|
return this.eventoService.geteventosDisponiblesMasDosDias()
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-16 16:49:52 -06:00
|
|
|
}
|