Browse Source

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 8 years ago
parent
commit
a2c52265d6

+ 2
- 1
Luticate2.Utils/Business/LuCrudBusiness.cs View File

164
         public LuResult<LuPaginatedDbo<TDboRead>> GetMultiple(LuOrderByDbo orderBy, int page = 0,
164
         public LuResult<LuPaginatedDbo<TDboRead>> GetMultiple(LuOrderByDbo orderBy, int page = 0,
165
             int perPage = int.MaxValue)
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 View File

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

+ 33
- 0
Luticate2.Utils/Controllers/LuUtilsExtensions.cs View File

64
             return 418;
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
         public static IDictionary<object, object> GetLuItems(this HttpContext context)
100
         public static IDictionary<object, object> GetLuItems(this HttpContext context)
68
         {
101
         {
69
             return (IDictionary<object, object>) context.Items["luticateItems"];
102
             return (IDictionary<object, object>) context.Items["luticateItems"];

+ 0
- 2
Luticate2.Utils/DataAccess/LuEfCrudDataAccess.cs View File

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

+ 1
- 1
Luticate2.Utils/Middlewares/LuExceptionMiddleware.cs View File

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

+ 2
- 2
WebTest/Startup.cs View File

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

Loading…
Cancel
Save