diff --git a/src/hora-excepcion/dto/hora-excepcion-create.dto.ts b/src/hora-excepcion/dto/hora-excepcion-create.dto.ts index 2208fb9..e3fff5b 100644 --- a/src/hora-excepcion/dto/hora-excepcion-create.dto.ts +++ b/src/hora-excepcion/dto/hora-excepcion-create.dto.ts @@ -2,5 +2,5 @@ import { IsInt } from 'class-validator'; export class HoraExcepcionDto { @IsInt() - id_institucion: number; + id_institucion_dia: number; } diff --git a/src/hora-excepcion/hora-excepcion.controller.ts b/src/hora-excepcion/hora-excepcion.controller.ts index 7e93a4d..67d4eab 100644 --- a/src/hora-excepcion/hora-excepcion.controller.ts +++ b/src/hora-excepcion/hora-excepcion.controller.ts @@ -9,7 +9,7 @@ export class HoraExcepcionController { @Post() create(@Body() body: HoraExcepcionDto) { - return this.horaExcepcionService.create(body.id_institucion) + return this.horaExcepcionService.create(body.id_institucion_dia) } @Delete(':id') diff --git a/src/hora-excepcion/hora-excepcion.service.ts b/src/hora-excepcion/hora-excepcion.service.ts index e639d8b..a777570 100644 --- a/src/hora-excepcion/hora-excepcion.service.ts +++ b/src/hora-excepcion/hora-excepcion.service.ts @@ -2,23 +2,22 @@ import { ConflictException, NotFoundException, Injectable } from '@nestjs/common import { InjectRepository } from '@nestjs/typeorm'; import { Repository } from 'typeorm'; import { HoraExcepcion } from './entity/hora-excepcion.entity'; -import { InstitucionService } from '../institucion/institucion.service'; - +import { InstitucionDiaService } from '../institucion-dia/institucion-dia.service' @Injectable() export class HoraExcepcionService { constructor( @InjectRepository(HoraExcepcion) private repository: Repository, - private institucionService: InstitucionService - ) {} + private institucionDiaService: InstitucionDiaService, + ) { } - async create(id_institucion: number) { - const institucion = await this.institucionService.findById(id_institucion) - const nuevaHoraExcepcion = this.repository.create({institucion}); + async create(id_institucion_dia: number) { + const institucionDia = await this.institucionDiaService.findById(id_institucion_dia) + const nuevaHoraExcepcion = this.repository.create({institucionDia}); return this.repository - .findOne({institucion}) + .findOne({institucionDia}) .then((existeHoraExcepcion) => { if (existeHoraExcepcion) throw new ConflictException('Ya existe esta hora excepción') return this.repository.save(nuevaHoraExcepcion)