This commit is contained in:
Paolo Arena
2021-02-18 12:19:35 +01:00
parent 88ae9af12c
commit 14a3292da2
22 changed files with 233 additions and 122 deletions

View File

@@ -28,7 +28,7 @@ router.post('/', authenticate, (req, res) => {
// tools.mylog('INIZIO - booking');
// tools.mylog('req.body', req.body);
const myrec = _.pick(req.body, tools.allfieldBooking());
const id = myrec._id;
const id = myrec.id_bookedevent;
const fieldtochange = _.pick(myrec, tools.allfieldBookingChange());
tools.mylog('crea Booking');
@@ -45,13 +45,13 @@ router.post('/', authenticate, (req, res) => {
// console.log('trovato', trovato);
if (trovato) {
return Booking.findOneAndUpdate({ id_bookedevent: id }, { $set: fieldtochange }, {
new: true,
new: false,
upsert: true
}).then((recbooking) => {
// tools.mylog('booking:', booking);
// tools.mylog('already exist');
sendNotif(res, myrec.idapp, req.user, recbooking);
res.send({ code: server_constants.RIS_CODE_OK, msg: '', id: recbooking._id });
sendNotif(res, myrec.idapp, req.user, myrec);
res.send({ code: server_constants.RIS_CODE_OK, msg: '', id: id_bookedevent });
});
} else {
// save to database a new record
@@ -62,8 +62,8 @@ router.post('/', authenticate, (req, res) => {
Booking.findById(idobj)
.then((recbooking) => {
sendNotif(res, myrec.idapp, req.user, recbooking);
res.send({ code: server_constants.RIS_CODE_OK, msg: '', id: recbooking._id });
sendNotif(res, myrec.idapp, req.user, writeresult);
res.send({ code: server_constants.RIS_CODE_OK, msg: '', id: writeresult._id });
});
});
}