29 lines
833 B
JavaScript
29 lines
833 B
JavaScript
const { validarId } = require('../../helper/validar');
|
|
const dbPath = '../../db/tablas';
|
|
const TercerSemestre = require(`${dbPath}/TercerSemestre`);
|
|
|
|
const get = async (body) => {
|
|
const idTercerSemestre = validarId(body.idTercerSemestre);
|
|
|
|
/*
|
|
Falta
|
|
Enviar correo con qr de confirmación de su registro a su
|
|
email pcpuma
|
|
*/
|
|
return TercerSemestre.findOne({ where: { idTercerSemestre } })
|
|
.then((res) => {
|
|
if (!res) throw new Error('No existe esta alumno.');
|
|
if (res.deseaAsistir)
|
|
throw new Error('Ya se registro a este alumno al recorrido.');
|
|
return TercerSemestre.update(
|
|
{ deseaAsistir: true },
|
|
{ where: { idTercerSemestre } }
|
|
);
|
|
})
|
|
.then((res) => ({
|
|
message: 'Se ha registrado correctamente al alumno al recorrido.',
|
|
}));
|
|
};
|
|
|
|
module.exports = get;
|