manejo de errores
This commit is contained in:
@@ -11,19 +11,28 @@ const ahora = moment();
|
||||
const inscripcion = async (body) => {
|
||||
const idUsuario = validarNumeroEntero(body.idUsuario, 'id Usuario', true);
|
||||
const idArea = validarNumeroEntero(body.idArea, 'id Area', true);
|
||||
|
||||
return Inscripcion.create({
|
||||
idUsuario,
|
||||
confirmacion: true,
|
||||
folio: body.folio,
|
||||
monto: body.monto,
|
||||
idArea,
|
||||
fechaIncripcion: ahora.format(),
|
||||
fechaTicket: body.fechaTicket,
|
||||
idFechaInscripcion: body.idFechaInscripcion,
|
||||
}).then((res) => ({
|
||||
message: '¡La inscripción se realizo de manera correcta!',
|
||||
}));
|
||||
return Inscripcion.findOne({
|
||||
where: { idArea: body.idArea },
|
||||
})
|
||||
.then((res) => {
|
||||
if (res) throw new Error('Usted ya esta inscrito a esta Area');
|
||||
return Inscripcion.create({
|
||||
idUsuario,
|
||||
confirmacion: true,
|
||||
folio: body.folio,
|
||||
monto: body.monto,
|
||||
idArea,
|
||||
fechaIncripcion: ahora.format(),
|
||||
fechaTicket: body.fechaTicket,
|
||||
idFechaInscripcion: body.idFechaInscripcion,
|
||||
});
|
||||
})
|
||||
.then((res) => ({
|
||||
message: '¡La inscripción se realizo de manera correcta!',
|
||||
}))
|
||||
.catch((err) => {
|
||||
throw new Error('No es posible realizar esta inscripción. ' + err);
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = inscripcion;
|
||||
|
||||
@@ -5,10 +5,9 @@ const Inscripcion = require(`${dbPath}/Inscripcion`);
|
||||
|
||||
const inscripciones = async (body) => {
|
||||
// const numeroCuenta = validar.validarNumeroCuenta(body.numeroCuenta);
|
||||
return Inscripcion.findOne({
|
||||
return Inscripcion.findAll({
|
||||
where: { idUsuario: body.idUsuario },
|
||||
}).then((res) => {
|
||||
console.log(res);
|
||||
if (!res) return [];
|
||||
return Inscripcion.findAll({
|
||||
where: { idUsuario: body.idUsuario },
|
||||
|
||||
Reference in New Issue
Block a user