-
Notifications
You must be signed in to change notification settings - Fork 4
/
Meeting.js
98 lines (79 loc) · 2.21 KB
/
Meeting.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
const Building = require('./Building').Building;
const Errors = require('./Errors').Errors;
const error = new Errors();
class Meeting {
constructor() {
this.buildings = {};
}
addBuilding(name) {
if(this.buildings[name] !== undefined) {
return {
success: false,
error: error.getError(2)
}
}
let building = new Building(name);
this.buildings = {
...this.buildings,
[name]: building,
}
return {
success: true,
data: building,
};
}
addFloor(buildingName, floorName) {
let res = this.getBuildingByName(buildingName);
if(!res['success']) {
return res;
}
let building = res['data'];
return building.addFloor(floorName);
}
addRoom(buildingName, floorName, roomName) {
let res = this.getBuildingByName(buildingName);
if(!res['success']) {
return res;
}
let building = res['data'];
return building.addRoom(floorName, roomName);
}
bookSlot(buildingName, floorName, roomName, slot) {
let res = this.getBuildingByName(buildingName);
if(!res['success']) {
return res;
}
let building = res['data'];
return building.bookSlot(floorName, roomName, slot);
}
cancelSlot(buildingName, floorName, roomName, slot) {
let res = this.getBuildingByName(buildingName);
if(!res['success']) {
return res;
}
let building = res['data'];
return building.cancelSlot(floorName, roomName, slot);
}
getAllBooking(buildingName, floorName) {
}
getBuildingByName(name) {
let building = this.buildings[name];
if(building === undefined) {
return {
success: false,
error: error.getError(5)
}
}
return {
success: true,
data: building,
}
}
getNumberOfBuilding() {
return {
success: true,
data: Object.keys(this.buildings).length,
};
}
};
module.exports.Meeting = Meeting;