text: 'use strict';
  
  angular.module('footierepoApp')
      .factory('AuditsService', function ($http) {
          return {
              findAll: function () {
                  return $http.get('api/audits/').then(function (response) {
                      return response.data;
                  });
              },
              findByDates: function (fromDate, toDate) {
  
                  var formatDate =  function (dateToFormat) {
                      if (dateToFormat !== undefined && !angular.isString(dateToFormat)) {
                          return dateToFormat.getYear() + '-' + dateToFormat.getMonth() + '-' + dateToFormat.getDay();
                      }
                      return dateToFormat;
                  };
  
                  return $http.get('api/audits/', {params: {fromDate: formatDate(fromDate), toDate: formatDate(toDate)}}).then(function (response) {
                      return response.data;
                  });
              }
          };
      });
  