|
@@ -0,0 +1,75 @@
|
|
1
|
+/**
|
|
2
|
+ * Created by robin on 10/24/15.
|
|
3
|
+ */
|
|
4
|
+
|
|
5
|
+angular.module('luticate', []);
|
|
6
|
+(function () {
|
|
7
|
+ 'use strict';
|
|
8
|
+ angular.module('luticate')
|
|
9
|
+ .factory('luticateUtils', ['$q', '$http', function ($q, $http) {
|
|
10
|
+
|
|
11
|
+ var coPlanningServices = {};
|
|
12
|
+
|
|
13
|
+ coPlanningServices.get = function(url, dataGet)
|
|
14
|
+ {
|
|
15
|
+ return coPlanningServices.request(url, 'GET', dataGet, null);
|
|
16
|
+ };
|
|
17
|
+
|
|
18
|
+ coPlanningServices.post = function(url, dataPost, dataGet)
|
|
19
|
+ {
|
|
20
|
+ return coPlanningServices.request(url, 'POST', dataGet, dataPost);
|
|
21
|
+ };
|
|
22
|
+
|
|
23
|
+ coPlanningServices.put = function(url, dataPost, dataGet)
|
|
24
|
+ {
|
|
25
|
+ return coPlanningServices.request(url, 'PUT', dataGet, dataPost);
|
|
26
|
+ };
|
|
27
|
+
|
|
28
|
+ coPlanningServices.delete = function(url, dataPost, dataGet)
|
|
29
|
+ {
|
|
30
|
+ return coPlanningServices.request(url, 'DELETE', dataGet, dataPost);
|
|
31
|
+ };
|
|
32
|
+
|
|
33
|
+ coPlanningServices.request = function(url, method, dataGet, dataPost)
|
|
34
|
+ {
|
|
35
|
+ var defered = $q.defer();
|
|
36
|
+
|
|
37
|
+ var params = {
|
|
38
|
+ url: url,
|
|
39
|
+ method: method,
|
|
40
|
+ params: dataGet,
|
|
41
|
+ data: dataPost
|
|
42
|
+ };
|
|
43
|
+
|
|
44
|
+ $http(params)
|
|
45
|
+ .success(function (result, status) {
|
|
46
|
+ if (result.Message != null) {
|
|
47
|
+ defered.reject({
|
|
48
|
+ data: result.Message,
|
|
49
|
+ status: status
|
|
50
|
+ });
|
|
51
|
+ }
|
|
52
|
+ else {
|
|
53
|
+ defered.resolve(result.Data);
|
|
54
|
+ }
|
|
55
|
+ })
|
|
56
|
+ .error(function (result, status) {
|
|
57
|
+ if (result.Message != null) {
|
|
58
|
+ defered.reject({
|
|
59
|
+ data: result.Message,
|
|
60
|
+ status: status
|
|
61
|
+ });
|
|
62
|
+ }
|
|
63
|
+ else {
|
|
64
|
+ defered.reject({
|
|
65
|
+ data: result,
|
|
66
|
+ status: status
|
|
67
|
+ });
|
|
68
|
+ }
|
|
69
|
+ });
|
|
70
|
+ return defered.promise;
|
|
71
|
+ };
|
|
72
|
+
|
|
73
|
+ return coPlanningServices;
|
|
74
|
+ }]);
|
|
75
|
+})();
|