creacion de dto para event y algunos servicios
This commit is contained in:
@@ -1,35 +1,50 @@
|
||||
import { Body, Controller, Delete, Get, HttpCode, HttpStatus, Param, Patch, Post } from '@nestjs/common';
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Get,
|
||||
HttpCode,
|
||||
HttpStatus,
|
||||
Param,
|
||||
Patch,
|
||||
Post,
|
||||
} from '@nestjs/common';
|
||||
import { CreateEventDto } from './dto/create-event.dto';
|
||||
import { event } from './event.entity';
|
||||
import { EventsService } from './events.service';
|
||||
|
||||
@Controller('events')
|
||||
export class EventsController {
|
||||
@Get()
|
||||
getEvents(): string{
|
||||
return "Aqui irán los eventos"
|
||||
}
|
||||
constructor(private readonly eventsServices: EventsService) {}
|
||||
|
||||
/* @Get(':id')
|
||||
@Get()
|
||||
getEvents(): event[] {
|
||||
return this.eventsServices.getEvents();
|
||||
}
|
||||
|
||||
/* @Get(':id')
|
||||
getEvent(@Param() params){
|
||||
return `El evento que estamos llamando es: ${params.id}`
|
||||
} */
|
||||
|
||||
@Get(':id')
|
||||
getEvent(@Param('id') id: string): string{
|
||||
return `El evento que estamos llamando es: ${id}`
|
||||
}
|
||||
@Get(':id')
|
||||
getEvent(@Param('id') id: string): event {
|
||||
return this.eventsServices.getEvent(parseInt(id));
|
||||
}
|
||||
|
||||
@Post()
|
||||
/* @HttpCode(HttpStatus.NO_CONTENT) esta linea es para no teornar nada*/
|
||||
createEvent(@Body('message') message: string){
|
||||
return `el evento creado es: ${message}`
|
||||
}
|
||||
@Post()
|
||||
createEvent(@Body() body: CreateEventDto): string {
|
||||
this.eventsServices.createEvent(body);
|
||||
return 'evento creado con exito';
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
deleteEvent(@Param('id') id:string): string{
|
||||
return `Estamos borrando el evento: ${id}`
|
||||
}
|
||||
@Delete(':id')
|
||||
deleteEvent(@Param('id') id: string) {
|
||||
return this.eventsServices.deleteEvent(parseInt(id));
|
||||
}
|
||||
|
||||
@Patch(':id')
|
||||
updateEvent(@Param('id') id:string, @Body() body){
|
||||
return `Actualizando el evento: ${id}`
|
||||
}
|
||||
}
|
||||
@Patch(':id')
|
||||
updateEvent(@Param('id') id: string, @Body() body) {
|
||||
return `Actualizando el evento: ${id}`;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user