2019-07-19 17:39:19 +00:00
|
|
|
/* global Events Reservations */
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
const _ = require('lodash');
|
|
|
|
|
const { generateService, parseParamsToFindOptions } = require('../../helpers/service.helper');
|
|
|
|
|
const models = require('../../core/models');
|
|
|
|
|
|
|
|
|
|
const extraMethods = {
|
|
|
|
|
|
2019-07-19 19:36:20 +00:00
|
|
|
_getReservaByCode: (eventId, code) => {
|
|
|
|
|
return models.EventReservation.findOne({
|
|
|
|
|
where: { reservation_code: code, eventId: eventId },
|
|
|
|
|
include: [{
|
|
|
|
|
model: models.Event,
|
|
|
|
|
}],
|
2019-07-19 17:39:19 +00:00
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
_updateReservation: (params, context) => {
|
|
|
|
|
|
|
|
|
|
const tickets = inscriptionCount + 1; // <- nº de inscritos + 1
|
|
|
|
|
|
|
|
|
|
return new Promise (function (resolve, reject) {
|
|
|
|
|
models.EventReservation.update({
|
|
|
|
|
confirmed: tickets
|
|
|
|
|
}, {
|
|
|
|
|
where: {
|
|
|
|
|
id: eventReservationid
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
module.exports = generateService(models.EventReservation, extraMethods);
|