Explorar el Código

[WebApiUtils] Added dbo for simple types

develop
Robin Thoni hace 9 años
padre
commit
ccf5386483

+ 6
- 6
WebAPiUtils-test/Controllers/ValuesController.cs Ver fichero

@@ -25,16 +25,16 @@ namespace WebAPiUtils_test.Controllers
25 25
 
26 26
         [HttpPost]
27 27
         [Route("api/values/edit/{id}")]
28
-        public bool Edit(long id, ValuesDboEdit obj)
28
+        public DboGetSingle<bool> Edit(long id, ValuesDboEdit obj)
29 29
         {
30
-            return Handle(ValuesBusiness.Edit(obj, id));
30
+            return HandleSingle(ValuesBusiness.Edit(obj, id));
31 31
         }
32 32
 
33 33
         [HttpPost]
34 34
         [Route("api/values/add")]
35
-        public long Add(ValuesDboAdd obj)
35
+        public DboGetSingle<long> Add(ValuesDboAdd obj)
36 36
         {
37
-            return Handle(ValuesBusiness.Add(obj));
37
+            return HandleSingle(ValuesBusiness.Add(obj));
38 38
         }
39 39
 
40 40
         [HttpPost]
@@ -46,9 +46,9 @@ namespace WebAPiUtils_test.Controllers
46 46
 
47 47
         [HttpPost]
48 48
         [Route("api/values/upload")]
49
-        public string Upload()
49
+        public DboGetSingle<string> Upload()
50 50
         {
51
-            return Handle(SaveFileToTemp().Result);
51
+            return HandleSingle(SaveFileToTemp().Result);
52 52
         }
53 53
     }
54 54
 }

+ 15
- 0
WebApiUtils/BusinessManager/BMRHandler.cs Ver fichero

@@ -9,6 +9,7 @@ using System.Threading.Tasks;
9 9
 using System.Web.Http;
10 10
 using iiie.Logs.DataAccess;
11 11
 using iiie.Logs.DBO;
12
+using iiie.WebApiUtils.DBO;
12 13
 
13 14
 namespace iiie.WebApiUtils.BusinessManager
14 15
 {
@@ -72,6 +73,20 @@ namespace iiie.WebApiUtils.BusinessManager
72 73
             throw new HttpResponseException(msg);
73 74
         }
74 75
 
76
+        /// <summary>
77
+        /// Handle business manager results
78
+        /// </summary>
79
+        /// <param name="result">The result to handle</param>
80
+        /// <returns>The data to return to the user</returns>
81
+        [NonAction]
82
+        public DboGetSingle<T> HandleSingle<T>(OpResult<T> result)
83
+        {
84
+            return new DboGetSingle<T>
85
+            {
86
+                Value = Handle(result)
87
+            };
88
+        }
89
+
75 90
         /// <summary>
76 91
         /// Save the uploaded file to the temp dir
77 92
         /// </summary>

+ 7
- 0
WebApiUtils/DBO/DboGetSingle.cs Ver fichero

@@ -0,0 +1,7 @@
1
+namespace iiie.WebApiUtils.DBO
2
+{
3
+    public class DboGetSingle<TDboGet>
4
+    {
5
+        public TDboGet Value { get; set; }
6
+    }
7
+}

+ 1
- 0
WebApiUtils/WebApiUtils.csproj Ver fichero

@@ -97,6 +97,7 @@
97 97
     <Compile Include="BusinessManager\Attributes\ValidateModelStateAttribute.cs" />
98 98
     <Compile Include="BusinessManager\WebApiUtils.cs" />
99 99
     <Compile Include="DBO\DboGetMultiple.cs" />
100
+    <Compile Include="DBO\DboGetSingle.cs" />
100 101
     <Compile Include="Properties\AssemblyInfo.cs" />
101 102
   </ItemGroup>
102 103
   <ItemGroup>

Loading…
Cancelar
Guardar