Created
May 29, 2014 05:30
-
-
Save lazarofl/22b644976c9d4d2ae28c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('app').service('ComprasService', ['$http', function ($http) { | |
this.ObterListaDeCompras = function() { | |
return $http.get('/listadecompras').then(function(response) { | |
return response || null; | |
}, function(response) { | |
switch(response.status) | |
{ | |
default: | |
throw 'nenhuma informação'; | |
} | |
}); | |
}; | |
this.Adicionar = function(item) { | |
if(!!!item || !!!item.nome || !!!item.quantidade) | |
{ | |
throw 'item não está definido'; | |
} | |
return $http.post('/listadecompras', item).then(function(response) { | |
return response || null; | |
}, function(response) { | |
switch(response.status) | |
{ | |
default: | |
throw 'nenhuma informação'; | |
} | |
}); | |
}; | |
this.Atualizar = function(item) { | |
return $http.put('/listadecompras', item).then(function(response) { | |
return response || null; | |
}, function(response) { | |
switch(response.status) | |
{ | |
default: | |
throw 'nenhuma informação'; | |
} | |
}); | |
}; | |
this.Remover = function(item) { | |
return $http.delete('/listadecompras', item).then(function(response) { | |
return response || null; | |
}, function(response) { | |
switch(response.status) | |
{ | |
default: | |
throw 'nenhuma informação'; | |
} | |
}); | |
}; | |
}]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment