angular.module('ngBoilerplate.activeIngredient', ['ui.router', 'ngResource'])
.config(function($stateProvider) {

})
.factory('activeIngredientService', function($resource) {
    var service = {};
    service.getAllActiveIngredients = function() {
        console.log("getAllActiveIngredients");
          var ActiveIngredient = $resource("/basic-web-app/rest/activeIngredients");
          return ActiveIngredient.get().$promise.then(function(data) {
            return data.activeIngredients;
          });
    };
    service.getAllActiveIngredientsWithRecomendations = function() {
        console.log("getAllActiveIngredientsWithRecomendations");
          var ActiveIngredient = $resource("/basic-web-app/rest/activeIngredients/recomendations");
          return ActiveIngredient.get().$promise.then(function(data) {
            return data.activeIngredients;
          });
    };
    
    service.getActiveIngredientById = function(activeIngredientId) {
        console.log("getActiveIngredientById");
        var ActiveIngredient = $resource("/basic-web-app/rest/activeIngredienta/:paramActiveIngredientId");
        return ActiveIngredient.get({paramActiveIngredientId:activeIngredientId}).$promise;
    };
    
    service.getMyActiveIngredient = function() {
        console.log("getMyActiveIngredient");
        var ActiveIngredient = $resource("/basic-web-app/rest/activeIngredients");
            return ActiveIngredient.get().$promise.then(function(data) {
              return data.activeIngredients;
        });
    };
    
    service.uploadExcel = function(excelCsv, success, failure) {
        console.log("activeIngredient - uploadExcel");
        var ExcelCsv = $resource("/basic-web-app/rest/activeIngredients/excel");
        ExcelCsv.save({}, excelCsv, success, failure);
    };
    
    service.uploadExcelRecomendations = function(excelCsv, success, failure) {
        console.log("activeIngredient - uploadExcelRecomendations");
        var ExcelCsv = $resource("/basic-web-app/rest/activeIngredients/excelRecomendations");
        ExcelCsv.save({}, excelCsv, success, failure);
    };
    
    
    return service;
});
