Pārlūkot izejas kodu

error message for empty luresult public message; fixed crud business get mutliple pagination; switched services to transient to avoid side effect on dbcontext

tags/v0.1.0
Robin Thoni 7 gadus atpakaļ
vecāks
revīzija
a2c52265d6

+ 2
- 1
Luticate2.Utils/Business/LuCrudBusiness.cs Parādīt failu

@@ -164,7 +164,8 @@ namespace Luticate2.Utils.Business
164 164
         public LuResult<LuPaginatedDbo<TDboRead>> GetMultiple(LuOrderByDbo orderBy, int page = 0,
165 165
             int perPage = int.MaxValue)
166 166
         {
167
-            return DataAccess.GetMultiple(orderBy, 0, perPage);
167
+            var res = DataAccess.GetMultiple(orderBy, page, perPage);
168
+            return res;
168 169
         }
169 170
 
170 171
 

+ 1
- 0
Luticate2.Utils/Controllers/LuController.cs Parādīt failu

@@ -1,4 +1,5 @@
1 1
 using System.Collections.Generic;
2
+using System.Threading;
2 3
 using Luticate2.Utils.Dbo;
3 4
 using Luticate2.Utils.Dbo.Basic;
4 5
 using Luticate2.Utils.Dbo.Result;

+ 33
- 0
Luticate2.Utils/Controllers/LuUtilsExtensions.cs Parādīt failu

@@ -64,6 +64,39 @@ namespace Luticate2.Utils.Controllers
64 64
             return 418;
65 65
         }
66 66
 
67
+        public static string GetHttpString<T>(this LuResult<T> result)
68
+        {
69
+            if (result.Status == LuStatus.Success)
70
+            {
71
+                return "Success";
72
+            }
73
+            if (result.Status == LuStatus.InputError)
74
+            {
75
+                return "Bad User Input";
76
+            }
77
+            if (result.Status == LuStatus.LoginError)
78
+            {
79
+                return "Login Error";
80
+            }
81
+            if (result.Status == LuStatus.PermissionError)
82
+            {
83
+                return "Permission Error";
84
+            }
85
+            if (result.Status == LuStatus.NotFound)
86
+            {
87
+                return "Not Found";
88
+            }
89
+            if (result.Status == LuStatus.DbError)
90
+            {
91
+                return "Internal Error";
92
+            }
93
+            if (result.Status == LuStatus.InternalError)
94
+            {
95
+                return "Internal Error";
96
+            }
97
+            return "I'm a teapot";
98
+        }
99
+
67 100
         public static IDictionary<object, object> GetLuItems(this HttpContext context)
68 101
         {
69 102
             return (IDictionary<object, object>) context.Items["luticateItems"];

+ 0
- 2
Luticate2.Utils/DataAccess/LuEfCrudDataAccess.cs Parādīt failu

@@ -2,8 +2,6 @@
2 2
 using System.Collections.Generic;
3 3
 using System.Linq;
4 4
 using System.Linq.Expressions;
5
-using System.Reflection;
6
-using Luticate2.Utils.Dbo;
7 5
 using Luticate2.Utils.Dbo.Basic;
8 6
 using Luticate2.Utils.Dbo.OrderBy;
9 7
 using Luticate2.Utils.Dbo.Result;

+ 1
- 1
Luticate2.Utils/Middlewares/LuExceptionMiddleware.cs Parādīt failu

@@ -34,7 +34,7 @@ namespace Luticate2.Utils.Middlewares
34 34
                 {
35 35
                     code = e.Result.GetHttpCode(),
36 36
                     data = null,
37
-                    message = e.Result.PublicDetails
37
+                    message = e.Result.PublicDetails ?? e.Result.GetHttpString()
38 38
                 })).ConfigureAwait(false);
39 39
             }
40 40
             catch (Exception e)//TODO

+ 2
- 2
WebTest/Startup.cs Parādīt failu

@@ -40,8 +40,8 @@ namespace WebTest
40 40
 
41 41
             services.AddLuticateAuth();
42 42
 
43
-            services.AddSingleton<PkGuidBusiness>();
44
-            services.AddSingleton<LuUtilsPkGuidDataAccess>();
43
+            services.AddTransient<PkGuidBusiness>();
44
+            services.AddTransient<LuUtilsPkGuidDataAccess>();
45 45
             services.AddDbContext<LuUtilsDbContext>(options => options.UseNpgsql(Tests.ConnectionString));
46 46
 
47 47
             services.AddMvc()

Notiek ielāde…
Atcelt
Saglabāt