angular.module('webapp').factory('EventService', EventService)
EventService.$inject = ['$firebaseObject', 'Event']

/**
 * @ngdoc service
 * @name webapp.service:PlacesService
 * @description In charge of places management.
 */
function EventService($firebaseObject, Event) {
    var EventService = {}

    EventService._ref = new Firebase("https://ifac2017.firebaseio.com/event")

    EventService.event = $firebaseObject(EventService._ref)

    EventService.Model = Event

    EventService.loadEvent = function() {
        return EventService.event.$loaded()
    }

    EventService.save = function(event) {
        EventService.event.start_date = event.start_date.getTime()
        EventService.event.end_date = event.end_date.getTime()
        EventService.event.timeslots = event.timeslots.map(function(item) {
            return {
                start_time: item.start_time.getTime(),
                end_time: item.end_time.getTime()
            }
        })

        return EventService.event.$save()
    }

    return EventService
}

@@ -159,14 +159,13 @@
 ice:
-Places
+Event
 Serv
@@ -201,14 +201,13 @@
  of 
-places
+event
  man
@@ -302,268 +302,1552 @@
     
-EventService._ref = new Firebase(%22https://ifac2017.firebaseio.com/event%22)%0A%0A    EventService.event = $firebaseObject(EventService._ref)%0A%0A    EventService.Model = Event%0A%0A    EventService.loadEvent = function() %7B%0A        return EventService.event.$loaded()%0A    %7D%0A
+/**%0A     * @ngdoc property%0A     * @name _ref%0A     * @propertyOf webapp.service:EventService%0A     * @description Reference to the Firebase event database%0A     */%0A    EventService._ref = new Firebase(%22https://ifac2017.firebaseio.com/event%22)%0A%0A    /**%0A     * @ngdoc property%0A     * @name event%0A     * @propertyOf webapp.service:EventService%0A     * @description The current event%0A     */%0A    EventService.event = $firebaseObject(EventService._ref)%0A%0A    /**%0A     * @ngdoc property%0A     * @name Model%0A     * @propertyOf webapp.service:EventService%0A     * @description Event model%0A     */%0A    EventService.Model = Event%0A%0A    /**%0A     * @ngdoc method%0A     * @name loadEvent%0A     * @methodOf webapp.service:EventService%0A     * @description Return a promise indicating if the event is loaded%0A     * @returns %7BPromise%7D ok if the event is loaded%0A     * @example%0A      %60%60%60javascript%0A      EventService.loadEvent()%0A      .then(function() %7B%0A        // success...%0A      %7D)%0A      .catch(function(error) %7B%0A        // error...%0A      %7D)%0A      %60%60%60%0A      */%0A    EventService.loadEvent = function() %7B%0A        return EventService.event.$loaded()%0A    %7D%0A%0A    /**%0A     * @ngdoc method%0A     * @name save%0A     * @methodOf webapp.service:EventService%0A     * @description Return a promise indicating if the event was saved%0A     * @returns %7BPromise%7D ok if the event was saved%0A     * @example%0A      %60%60%60javascript%0A      EventService.save(event)%0A      .then(function() %7B%0A        // success...%0A      %7D)%0A      .catch(function(error) %7B%0A        // error...%0A      %7D)%0A      %60%60%60%0A      */
 %0A   

add event service documentation