-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpopulate.js
More file actions
166 lines (155 loc) · 5.61 KB
/
Copy pathpopulate.js
File metadata and controls
166 lines (155 loc) · 5.61 KB
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
import { Costumer, Pro, ProVIP, Place, Address, Demand, ServiceType, Service, City } from './app/models';
import moment from 'moment';
export function populate () {
//costumer stuff
// let costumer = new Costumer('joao', 'moura', 'joao@filipe.com', '123', '+1123456789');
// costumer.create()
// .then((costumer) => {
// console.log(costumer)
// costumer.password = 321;
// return costumer.update();
// }).then((costumer2) => {
// console.log(costumer2)
// }).catch((error) => {
// console.log(error)
// });
// costumer.create()
// .then((costumer) => {
// return costumer.remove()
// }).then((results) => {
// console.log(results)
// })
//---------------------------------------------------------------------------------------
//address and place stuff
// let city = new City('Tucson');
// let address = new Address('MEGASYSTEMS INC', '799 E DRAGRAM SUITE 5A', 'AZ', city, 85705);
// city.create()
// .then((city) => {
// console.log(city)
// address.city = city
// return address.create()
// }).then((address) => {
// console.log(address)
// address.zipCode = 12345
// return address.update()
// }).then((address) => {
// console.log(address)
// address.city.name = 'recife'
// let city = address.city.update()
// return { address: address, city: city }
// }).then(({ address: address, city: city }) => {
// return city.then((city) => {
// console.log(city)
// return Promise.all([city.remove(), address.remove()])
// })
// }).then((res) => {
// console.log(res)
// });
// let place = new Place(1, 1, 2, address);
// place.create()
// .then((place) => {
// console.log(place)
// place.size = 10
// return place.update()
// }).then((place) => {
// console.log(place)
// return place.remove()
// }).then((result) => {
// console.log(result)
// });
//-----------------------------------------------------------------------------------
//Pro stuff
// let pro = new Pro('pedro', 'Moura', 'pedro@moura.com', '123', '+1123456789', address , true, null, null, null);
// pro.create()
// .then((pro) => {
// console.log(pro)
// pro.firstName = 'joao'
// return pro.update()
// }).then((pro) => {
// console.log(pro)
// return pro.remove()
// }).then((result) => {
// console.log(result)
// });
// pro.create()
// .then((pro) => {
// console.log(pro)
// return new ProVIP(pro, '123456789', 'companyName').create();
// }).then((proVIP) => {
// console.log(proVIP)
// proVIP.companyName = 'myCompany'
// return proVIP.update()
// }).then((proVIP) => {
// console.log(proVIP)
// return proVIP.remove()
// }).then((res) => {
// console.log(res)
// return proVIP.remove()
// });
// ----------------------------------------------------------------------------------------
//Demand stuff
// let city = new City('Tucson');
// let serviceType = new ServiceType(null, 'house cleaning');
// let costumer = new Costumer('joao', 'moura', 'joao@filipe.com', '123', '+1123456789');
// let address = new Address('addressLine', 'addressLine2', 'az', city, 12345, 10, 10);
// let place = new Place(1, 1, 2, address);
// let dueDate = [];
// for (let i = 0; i < 10; i++) {
// dueDate.push([moment(Date.now()).format('YYYY-MM-DD HH:mm:ss'), moment(Date.now()).format('YYYY-MM-DD HH:mm:ss')])
// }
//
// city.create()
// .then((city) => {
// address.city = city
// return Promise.all([
// place.create(),
// costumer.create(),
// serviceType.create(),
// ])
// }).then((res) => {
// return new Demand(res[1], res[0], res[2], dueDate, 'details', true).create()
// }).then((demand) => {
// console.log(demand)
// return Promise.all([
// demand.place.remove(),
// demand.costumer.remove(),
// demand.serviceType.remove(),
// demand.remove()
// ])
// }).then((removed) => {
// console.log(removed)
// })
//-------------------------------------------------------------------------------------
//Service stuff
// let serviceType = new ServiceType(null, 'house cleaning');
// let costumer = new Costumer('joao', 'moura', 'joao@filipe.com', '123', '+1123456789');
// let address = new Address(null, 20, 'street', 'unit', 'city', 'st', 12345);
// let place = new Place(1, 1, 2, address);
// let pro = new Pro('pedro', 'Moura', 'pedro@moura.com', '123', '+1123456789', address , true, null, null, null);
//
// Promise.all([pro.create(), costumer.create(), place.create(), serviceType.create()])
// .then((res) => {
// let demand = new Demand(null, res[1], res[2], res[3], moment(Date.now()).format('YYYY-MM-DD HH:mm:ss'), 'details', true).create()
// return { demand: demand, res: res }
// }).then(({ demand: demand, res: res }) => {
// return demand.then((demand) => {
// let service = new Service(demand, res[0]).create()
// return { service: service, demand: demand }
// }).then(({ service: service, demand: demand }) => {
// return service.then((service) => {
// console.log(res)
// console.log(service)
// return Promise.all([
// res[0].remove(),
// res[1].remove(),
// res[2].remove(),
// res[3].remove(),
// demand.remove(),
// service.remove()
// ])
// })
// }).then((res) => {
// console.log(res)
// })
// });
}