Browse Source

[WebApiUtils] tests

feature/authentication-tests
Robin Thoni 9 years ago
parent
commit
1e5107289c

+ 5
- 0
WebAPiUtils-test/BusinessManager/ValuesBusiness.cs View File

21
         {
21
         {
22
             return ValuesManager.EditById(obj, id);
22
             return ValuesManager.EditById(obj, id);
23
         }
23
         }
24
+
25
+        public static OpResult<long> Add(ValuesDboAdd obj)
26
+        {
27
+            return ValuesManager.AddId(obj);
28
+        }
24
     }
29
     }
25
 }
30
 }

+ 7
- 0
WebAPiUtils-test/Controllers/ValuesController.cs View File

29
         {
29
         {
30
             return BMRHandler<bool>.Handle(ValuesBusiness.Edit(obj, id), Request);
30
             return BMRHandler<bool>.Handle(ValuesBusiness.Edit(obj, id), Request);
31
         }
31
         }
32
+
33
+        [HttpPost]
34
+        [Route("api/values/add")]
35
+        public long Edit(ValuesDboAdd obj)
36
+        {
37
+            return BMRHandler<long>.Handle(ValuesBusiness.Add(obj), Request);
38
+        }
32
     }
39
     }
33
 }
40
 }

+ 14
- 11
WebAPiUtils-test/DataAccess/ValuesManager.cs View File

25
             };
25
             };
26
         }
26
         }
27
 
27
 
28
-        public override T_SqlManager DboAddToDb(ValuesDboAdd obj)
28
+        public override OpResult<T_SqlManager> DboAddToDb(ValuesDboAdd obj)
29
         {
29
         {
30
-            return new T_SqlManager
30
+            var res = GetSingleById(obj.TextId);
31
+            if (!res)
32
+                return res.To<T_SqlManager>();
33
+            return OpResult<T_SqlManager>.Ok(new T_SqlManager
31
             {
34
             {
32
                 my_string = obj.MyString,
35
                 my_string = obj.MyString,
33
                 my_int = obj.MyInt,
36
                 my_int = obj.MyInt,
34
                 text = obj.TextId
37
                 text = obj.TextId
35
-            };
38
+            });
36
         }
39
         }
37
 
40
 
38
-        public override T_SqlManager DboEditToDb(ValuesDboEdit obj, T_SqlManager edit)
41
+        public override OpResult<T_SqlManager> DboEditToDb(ValuesDboEdit obj, T_SqlManager edit)
39
         {
42
         {
40
-            return new T_SqlManager
41
-            {
42
-                id = edit.id,
43
-                my_string = obj.MyString,
44
-                my_int = obj.MyInt,
45
-                text = obj.TextId
46
-            };
43
+            var res = GetSingleById(obj.TextId);
44
+            if (!res)
45
+                return res.To<T_SqlManager>();
46
+            edit.my_string = obj.MyString;
47
+            edit.my_int = obj.MyInt;
48
+            edit.text = obj.TextId;
49
+            return OpResult<T_SqlManager>.Ok(edit);
47
         }
50
         }
48
 
51
 
49
         public static OpResult<DboGetMultiple<ValuesDboGet>> Contains(string text, int page, int perPage)
52
         public static OpResult<DboGetMultiple<ValuesDboGet>> Contains(string text, int page, int perPage)

Loading…
Cancel
Save