65 lines
1.7 KiB
TypeScript
65 lines
1.7 KiB
TypeScript
import {
|
|
Body,
|
|
Controller,
|
|
NotFoundException,
|
|
Post,
|
|
} from '@nestjs/common';
|
|
import { InscripcionDscService } from './inscripcion-dsc.service';
|
|
|
|
@Controller('inscripcion-dsc')
|
|
export class InscripcionDscController {
|
|
constructor(private readonly inscripcionService: InscripcionDscService) {}
|
|
|
|
@Post('confirmacion')
|
|
async confirmacionDsc(@Body() body: any) {
|
|
const { accountNumber } = body;
|
|
console.log('Entro a la confirmacion')
|
|
|
|
const userVerification = await this.inscripcionService.userVerification(accountNumber);
|
|
/* console.log(userVerification) */
|
|
console.log('Usuario verificacion', userVerification);
|
|
if(!userVerification){
|
|
throw new NotFoundException('El usuario no se encuentra inscrito');
|
|
|
|
// return {
|
|
// error: true,
|
|
// msj: 'El usuario no se encuentra inscrito',
|
|
// desc: '',
|
|
// };
|
|
}
|
|
|
|
const userInformation = userVerification;
|
|
/* console.log(userInformation[0].confirmacion) */
|
|
|
|
|
|
try{
|
|
/* console.log("verificando confirmacion:", userInformation);
|
|
*/ if (userInformation[0].confirmacion) {
|
|
return {
|
|
error: true,
|
|
msj: 'El usuario ya hizo la confirmación anteriormente',
|
|
desc: '',
|
|
};
|
|
}
|
|
} catch (err) {
|
|
return console.log(err);
|
|
}
|
|
|
|
try {
|
|
const confirmationResponse =
|
|
await this.inscripcionService.userConfirmation(accountNumber);
|
|
return {
|
|
error: false,
|
|
msj: 'Usuario confirmado exitosamente',
|
|
data: confirmationResponse,
|
|
};
|
|
} catch (err) {
|
|
return {
|
|
error: true,
|
|
msj: `No se pudo realizar la confirmación del usuario`,
|
|
desc: `${err}`,
|
|
};
|
|
}
|
|
}
|
|
}
|