|
15 | 15 | //initialize array of events
|
16 | 16 | $scope.events = [];
|
17 | 17 |
|
18 |
| - //DateTime.Now.ToString("dd-MM-yyyy") |
19 |
| - |
20 |
| - //function get ponctual event |
| 18 | + //function get event by date |
21 | 19 | $scope.getEvent = function () {
|
22 | 20 | $scope.events = [];
|
| 21 | + |
| 22 | + // var dateselected = new Date($scope.dateSelected).toJSON(); |
| 23 | + |
23 | 24 | var responseEvent = $http({
|
| 25 | + // url: '/api/events/bydate', |
24 | 26 | url: '/api/ponctualEvents',
|
25 | 27 | method: 'GET',
|
| 28 | + // data: { eventdate: dateselected }, |
26 | 29 | headers: {
|
27 | 30 | 'Content-Type': 'application/json'
|
28 | 31 | }
|
29 | 32 | }).then(function successCallback(responseEvent) {
|
30 | 33 | console.log(responseEvent);
|
| 34 | + //console.log(new Date($scope.dateSelected).toJSON()); |
31 | 35 |
|
32 | 36 | //var for displaying or not the join button
|
33 |
| - if (new Date($scope.dateSelected) < today) { |
| 37 | + if (new Date($scope.dateSelected) < today) { |
34 | 38 | $scope.pastevent = true;
|
35 | 39 | }
|
36 | 40 | else
|
37 | 41 | {
|
38 | 42 | $scope.pastevent = false;
|
39 | 43 | }
|
40 |
| - for (var e in responseEvent.data) { |
41 |
| - |
42 |
| - var date = new Date(responseEvent.data[e].eventDate); |
43 |
| - date = date.getMonth() + 1 + "/" + date.getDate() + "/" + date.getFullYear(); |
44 |
| - |
45 |
| - // add this event to the list if it's current date |
46 |
| - if (date == $scope.dateSelected) { |
47 |
| - $scope.events.push({ |
48 |
| - Id: responseEvent.data[e].eventId, |
49 |
| - roomName: responseEvent.data[e].event.room.roomName, |
50 |
| - Description: responseEvent.data[e].event.eventDescription, |
51 |
| - timeBegin: responseEvent.data[e].event.timeBegin, |
52 |
| - duration: responseEvent.data[e].event.eventDurationHours, |
53 |
| - price: responseEvent.data[e].event.eventPrice, |
54 |
| - name: responseEvent.data[e].event.eventName, |
55 |
| - activity: responseEvent.data[e].event.activity.activityName |
56 |
| - }); |
57 |
| - } |
| 44 | + for (var e in responseEvent.data) { |
| 45 | + $scope.events.push({ |
| 46 | + Id: responseEvent.data[e].eventId, |
| 47 | + roomName: responseEvent.data[e].event.room.roomName, |
| 48 | + Description: responseEvent.data[e].event.eventDescription, |
| 49 | + timeBegin: responseEvent.data[e].event.timeBegin, |
| 50 | + duration: responseEvent.data[e].event.eventDurationHours, |
| 51 | + price: responseEvent.data[e].event.eventPrice, |
| 52 | + name: responseEvent.data[e].event.eventName, |
| 53 | + activity: responseEvent.data[e].event.activity.activityName |
| 54 | + }); |
| 55 | + |
58 | 56 | }
|
59 | 57 | if ($scope.events.length == 0) {
|
60 | 58 | bootbox.alert("There is no event for this day");
|
|
0 commit comments