restore create
This commit is contained in:
@@ -10,10 +10,10 @@ import { AlumnoInscrito } from './entities/alumno_inscrito.entity';
|
||||
export class AlumnoInscritoController {
|
||||
constructor(private readonly alumnoInscritoService: AlumnoInscritoService) {}
|
||||
|
||||
// @Post()
|
||||
// async create(@Body() dto: CreateAlumnoInscritoDto): Promise<AlumnoInscrito> {
|
||||
// return this.alumnoInscritoService.create(dto);
|
||||
// }
|
||||
@Post()
|
||||
async create(@Body() dto: CreateAlumnoInscritoDto): Promise<AlumnoInscrito> {
|
||||
return this.alumnoInscritoService.createWhitoutPay(dto);
|
||||
}
|
||||
|
||||
@Get()
|
||||
async findAll(): Promise<AlumnoInscrito[]> {
|
||||
|
||||
@@ -19,33 +19,34 @@ export class AlumnoInscritoService {
|
||||
private readonly periodoService: PeriodoService,
|
||||
) {}
|
||||
|
||||
//Borrar
|
||||
// async createBorrar(dto: CreateAlumnoInscritoDto): Promise<AlumnoInscrito> {
|
||||
// const periodoActivo = await this.periodoService.getPeriodoActivo();
|
||||
async createWhitoutPay(
|
||||
dto: CreateAlumnoInscritoDto,
|
||||
): Promise<AlumnoInscrito> {
|
||||
const periodoActivo = await this.periodoService.getPeriodoActivo();
|
||||
|
||||
// const existing = await this.alumnoInscritoRepo.findOne({
|
||||
// where: {
|
||||
// alumno: { id_cuenta: dto.id_cuenta },
|
||||
// periodo: { id_periodo: periodoActivo.id_periodo },
|
||||
// plataforma: { id_plataforma: dto.id_plataforma },
|
||||
// },
|
||||
// });
|
||||
const existing = await this.alumnoInscritoRepo.findOne({
|
||||
where: {
|
||||
alumno: { id_cuenta: dto.id_cuenta },
|
||||
periodo: { id_periodo: periodoActivo.id_periodo },
|
||||
plataforma: { id_plataforma: dto.id_plataforma },
|
||||
},
|
||||
});
|
||||
|
||||
// if (existing) {
|
||||
// throw new BadRequestException(
|
||||
// 'El alumno ya está inscrito en este periodo y plataforma',
|
||||
// );
|
||||
// }
|
||||
if (existing) {
|
||||
throw new BadRequestException(
|
||||
'El alumno ya está inscrito en este periodo y plataforma',
|
||||
);
|
||||
}
|
||||
|
||||
// const alumnoInscrito = this.alumnoInscritoRepo.create({
|
||||
// realizo_pago: dto.realizo_pago ?? false,
|
||||
// alumno: { id_cuenta: dto.id_cuenta },
|
||||
// plataforma: { id_plataforma: dto.id_plataforma },
|
||||
// periodo: periodoActivo,
|
||||
// });
|
||||
const alumnoInscrito = this.alumnoInscritoRepo.create({
|
||||
realizo_pago: dto.realizo_pago ?? false,
|
||||
alumno: { id_cuenta: dto.id_cuenta },
|
||||
plataforma: { id_plataforma: dto.id_plataforma },
|
||||
periodo: periodoActivo,
|
||||
});
|
||||
|
||||
// return this.alumnoInscritoRepo.save(alumnoInscrito);
|
||||
// }
|
||||
return this.alumnoInscritoRepo.save(alumnoInscrito);
|
||||
}
|
||||
|
||||
async findAll(): Promise<AlumnoInscrito[]> {
|
||||
return this.alumnoInscritoRepo.find({
|
||||
@@ -58,8 +59,8 @@ export class AlumnoInscritoService {
|
||||
return this.plataformaRepo.find();
|
||||
}
|
||||
|
||||
async findPlataformaById(id_plataforma:number) {
|
||||
return this.plataformaRepo.findOne({where:{id_plataforma}});
|
||||
async findPlataformaById(id_plataforma: number) {
|
||||
return this.plataformaRepo.findOne({ where: { id_plataforma } });
|
||||
}
|
||||
|
||||
async findById(id_cuenta: number): Promise<AlumnoInscrito[]> {
|
||||
|
||||
Reference in New Issue
Block a user