diff --git a/src/carrera-programa/carrera-programa.controller.ts b/src/carrera-programa/carrera-programa.controller.ts index 1c25597..f7a27b5 100644 --- a/src/carrera-programa/carrera-programa.controller.ts +++ b/src/carrera-programa/carrera-programa.controller.ts @@ -1,4 +1,4 @@ -import { Body, Controller, Delete, Get, Post, Put } from '@nestjs/common'; +import { Body, Controller, Delete, Get, Param, Post, Put } from '@nestjs/common'; import { CarreraProgramaService } from './carrera-programa.service'; import { CarreraProgramaCreateDto } from './dto/carrera-programa-create.dto'; import { CarreraProgramaUpdateDto } from './dto/carrera-programa-update.dto'; @@ -16,16 +16,13 @@ export class CarreraProgramaController { } // terminar delte - @Delete() - delete() {} + @Delete(':id') + delete(@Param('id') id_carrera_programa: number) { + return this.carreraProgramaService.delete(id_carrera_programa) + } @Get() get() { return this.carreraProgramaService.findAll(); } - - @Put() - update(@Body() body: CarreraProgramaUpdateDto) { - return this.carreraProgramaService.update(body); - } } diff --git a/src/carrera-programa/carrera-programa.service.ts b/src/carrera-programa/carrera-programa.service.ts index 5680a6e..7dd9b3e 100644 --- a/src/carrera-programa/carrera-programa.service.ts +++ b/src/carrera-programa/carrera-programa.service.ts @@ -47,25 +47,16 @@ export class CarreraProgramaService { .findOne({ id_carrera_programa }) .then((carreraPrograma) => { if (!carreraPrograma) - throw new NotFoundException('No existe esta carrera programa'); + throw new NotFoundException('No existe esta carrera-programa'); return carreraPrograma; }); } - // Eliminar update, no tiene sentido tenerlo, me equivoque xd - async update(attrs: Partial) { - const carreraPrograma = await this.findById(attrs.id_carrera_programa); - - return this.repository - .findOne({ id_carrera_programa: attrs.id_carrera_programa }) - .then((existeCarreraPrograma) => { - if (existeCarreraPrograma) - throw new ConflictException('Ya existe esta carrera programa'); - Object.assign(carreraPrograma, attrs); - return this.repository.save(carreraPrograma); - }) - .then(() => ({ - message: 'Se actualizo correctamente la carrera programa', - })); + //No estoy seguro de que esto este bien :) + delete(id_carrera_programa: number) { + this.findById(id_carrera_programa) + .then(() => { + return this.repository.delete(id_carrera_programa) + }) } }