67 lines
2.1 KiB
TypeScript
67 lines
2.1 KiB
TypeScript
import { Body, Controller, Delete, Get, Param, ParseIntPipe, Patch, Post, Res } 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';
|
|
|
|
@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)
|
|
}
|
|
|
|
@Post()
|
|
postEvento(@Body() nuevoEvento: crearEventoDto){
|
|
return this.eventoService.postEvento(nuevoEvento)
|
|
}
|
|
|
|
@Patch(':id')
|
|
patchEvento(@Param('id', ParseIntPipe)id:number, @Body() actualizacion: actualizarEventoDto){
|
|
return this.eventoService.updateEvento(id,actualizacion)
|
|
}
|
|
|
|
@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)
|
|
}
|
|
|
|
@Get(':id/participante')
|
|
async getParticipnates(@Param('id', ParseIntPipe)id:number){
|
|
return this.eventoService.getParticipantes(id)
|
|
}
|
|
|
|
@Get(':id/exportExcel')
|
|
async exportarExcel (@Param('id', ParseIntPipe)id:number ,@Res() res: Response){
|
|
this.eventoService.exportarParticipantes(id, res)
|
|
}
|
|
|
|
@Post('disponibles')
|
|
getEventosDisponibles (){
|
|
return this.eventoService.getEventosDisponibles()
|
|
}
|
|
|
|
@Post('disponibles/pendientesDconstancia')
|
|
getEventosDisponiblesPendientes(){
|
|
return this.eventoService.geteventosDisponiblesMasDosDias()
|
|
}
|
|
|
|
}
|