cuestionario temporal
This commit is contained in:
@@ -2,6 +2,66 @@ const validar = require('../../helper/validar');
|
||||
const CuestionarioPrograma = require('../../db/tablas/CuestionarioPrograma');
|
||||
const Servicio = require('../../db/tablas/Servicio');
|
||||
|
||||
const nuevo = async (body) => {};
|
||||
const nuevo = async (body) => {
|
||||
let idServicio = validar.validarId(body.idServicio);
|
||||
let actividadUno = '';
|
||||
let actividadDos = '';
|
||||
let actividadTres = '';
|
||||
let actividadCuatro = '';
|
||||
let actividadCinco = '';
|
||||
let retroalimentacion = '';
|
||||
let pSeis = '';
|
||||
let pSiete = '';
|
||||
|
||||
return Servicio.findOne({ where: { idServicio } })
|
||||
.then((res) => {
|
||||
if (!res) throw new Error('No existe este Servicio Social.');
|
||||
if (res.idCuestionarioPrograma)
|
||||
throw new Error(
|
||||
'Este Servicio Social ya cuenta con cuestionario de programa'
|
||||
);
|
||||
switch (res.idStatus) {
|
||||
case 4:
|
||||
return CuestionarioPrograma.create({
|
||||
actividadUno,
|
||||
actividadDos,
|
||||
actividadTres,
|
||||
actividadCuatro,
|
||||
actividadCinco,
|
||||
retroalimentacion,
|
||||
pSeis,
|
||||
pSiete,
|
||||
});
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
throw new Error(
|
||||
'Aun no se puede contestar el cuestionario este Servicio Social.'
|
||||
);
|
||||
case 5:
|
||||
case 6:
|
||||
throw new Error(
|
||||
'Este Servicio Social ya paso la fase de contestar el cuestionario.'
|
||||
);
|
||||
case 7:
|
||||
case 8:
|
||||
case 9:
|
||||
throw new Error(
|
||||
'Este Servicio Social se encuentra rechazado. No se puede avanzar hasta que se corriga lo necesario.'
|
||||
);
|
||||
case 10:
|
||||
throw new Error('Este Servicio Social esta cancelado.');
|
||||
}
|
||||
})
|
||||
.then((res) => {
|
||||
return Servicio.update(
|
||||
{ idCuestionarioPrograma: res.idCuestionarioPrograma },
|
||||
{ where: { idServicio } }
|
||||
);
|
||||
})
|
||||
.then((res) => {
|
||||
return { message: 'Se guardo tus respuestas correctamente.' };
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = nuevo;
|
||||
|
||||
Reference in New Issue
Block a user