cancelar servicio
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
const validar = require('../../helper/validar');
|
||||
const Servicio = require('../../db/tablas/Servicio');
|
||||
|
||||
const cancelar = async (body) => {
|
||||
let idServicio = validar.validarId(body.idServicio);
|
||||
|
||||
return Servicio.findOne({ where: { idServicio } })
|
||||
.then((res) => {
|
||||
if (!res) throw new Error('No existe este servicio.');
|
||||
if (res.idStatus === 10)
|
||||
throw new Error('Este servicio ya fue cancelado');
|
||||
return Servicio.update({ idStatus: 10 }, { where: { idServicio } });
|
||||
})
|
||||
.then((res) => {
|
||||
return { message: 'Se cancelo correctamente el servicio.' };
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = cancelar;
|
||||
|
||||
Reference in New Issue
Block a user