Browse Source

[WebApiUtils] Added dbo for simple types

develop
Robin Thoni 9 years ago
parent
commit
ccf5386483

+ 6
- 6
WebAPiUtils-test/Controllers/ValuesController.cs View File

25
 
25
 
26
         [HttpPost]
26
         [HttpPost]
27
         [Route("api/values/edit/{id}")]
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
         [HttpPost]
33
         [HttpPost]
34
         [Route("api/values/add")]
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
         [HttpPost]
40
         [HttpPost]
46
 
46
 
47
         [HttpPost]
47
         [HttpPost]
48
         [Route("api/values/upload")]
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 View File

9
 using System.Web.Http;
9
 using System.Web.Http;
10
 using iiie.Logs.DataAccess;
10
 using iiie.Logs.DataAccess;
11
 using iiie.Logs.DBO;
11
 using iiie.Logs.DBO;
12
+using iiie.WebApiUtils.DBO;
12
 
13
 
13
 namespace iiie.WebApiUtils.BusinessManager
14
 namespace iiie.WebApiUtils.BusinessManager
14
 {
15
 {
72
             throw new HttpResponseException(msg);
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
         /// <summary>
90
         /// <summary>
76
         /// Save the uploaded file to the temp dir
91
         /// Save the uploaded file to the temp dir
77
         /// </summary>
92
         /// </summary>

+ 7
- 0
WebApiUtils/DBO/DboGetSingle.cs View File

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 View File

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

Loading…
Cancel
Save