75 lines
1.8 KiB
TypeScript
75 lines
1.8 KiB
TypeScript
import {
|
|
Body,
|
|
Controller,
|
|
Get,
|
|
Param,
|
|
ParseIntPipe,
|
|
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;
|
|
|
|
/* this.inscripcionService
|
|
.userVerification({ accountNumber })
|
|
.then((res) => {
|
|
console.log(res);
|
|
})
|
|
.catch((err) => {
|
|
return(err)
|
|
}); */
|
|
|
|
try {
|
|
const userVerificationResponse =
|
|
await this.inscripcionService.userVerification({
|
|
accountNumber,
|
|
});
|
|
console.log(userVerificationResponse)
|
|
if (userVerificationResponse.length === 0) {
|
|
return {
|
|
error: true,
|
|
msj: 'El usuario no se encuentra inscrito',
|
|
desc: '',
|
|
};
|
|
}
|
|
const [userInformation] = userVerificationResponse;
|
|
console.log(userInformation);
|
|
if (userInformation.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}`,
|
|
};
|
|
}
|
|
}
|
|
|
|
/* @Get(":id")
|
|
getUsuarioById(@Param('id', ParseIntPipe)id: number){
|
|
|
|
} */
|
|
}
|