add mapping; store resourceId in doorLockEvents table
This commit is contained in:
@@ -15,7 +15,7 @@ const fetchAllBookings = () => {
|
||||
cleanedBookingReservations.push({
|
||||
reservationId: fullBookingEntry['_id'],
|
||||
memberId: fullBookingEntry.member,
|
||||
resource: fullBookingEntry.resourceId,
|
||||
resourceId: fullBookingEntry.resourceId,
|
||||
start: fullBookingEntry.start.dateTime,
|
||||
end: fullBookingEntry.end.dateTime,
|
||||
});
|
||||
@@ -29,9 +29,7 @@ const fetchAllBookings = () => {
|
||||
};
|
||||
|
||||
const writeBookingReservation = (bookingReservation) => {
|
||||
db.bookingReservation.findOrCreate({where: {...bookingReservation}, defaults: {...bookingReservation}})
|
||||
.then()
|
||||
.catch();
|
||||
return db.bookingReservation.findOrCreate({where: {...bookingReservation}, defaults: {...bookingReservation}});
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
|
||||
61
services/officeRnD/resources.js
Normal file
61
services/officeRnD/resources.js
Normal file
@@ -0,0 +1,61 @@
|
||||
'use strict';
|
||||
|
||||
const db = require('../../models/index');
|
||||
|
||||
const { API } = require('../../helpers/api');
|
||||
|
||||
const fetchOffices = () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
API.get('/offices')
|
||||
.then((result) => {
|
||||
const offices = result.data || [];
|
||||
const cleanedOffices = [];
|
||||
offices.forEach(office => {
|
||||
cleanedOffices.push({
|
||||
officeId: office['_id'],
|
||||
officeName: office.name,
|
||||
});
|
||||
});
|
||||
resolve(cleanedOffices);
|
||||
})
|
||||
.catch((error) => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const fetchResources = () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
API.get('/resources')
|
||||
.then((result) => {
|
||||
const resources = result.data || [];
|
||||
const cleanedResources = [];
|
||||
resources.forEach(resource => {
|
||||
cleanedResources.push({
|
||||
resourceId: resource['_id'],
|
||||
resourceName: resource.name,
|
||||
officeId: resource.office,
|
||||
});
|
||||
});
|
||||
resolve(cleanedResources);
|
||||
})
|
||||
.catch((error) => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const getMappingsFromDatabase = () => {
|
||||
return db.officeResourceMapping.findAll();
|
||||
};
|
||||
|
||||
const saveNewMappingToDatabase = (mapping) => {
|
||||
return db.officeResourceMapping.findOrCreate({where: {...mapping}, defaults: {...mapping}});
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
getMappingsFromDatabase,
|
||||
fetchOffices,
|
||||
fetchResources,
|
||||
saveNewMappingToDatabase,
|
||||
};
|
||||
Reference in New Issue
Block a user