Browse Source

generifyed long/string id; begin websockets

tags/v0.1.0
Robin Thoni 7 years ago
parent
commit
4d9eea629e

+ 27
- 105
Luticate2.Utils/Business/LuCrudBusiness.cs View File

@@ -8,8 +8,10 @@ using Luticate2.Utils.Interfaces;
8 8
 
9 9
 namespace Luticate2.Utils.Business
10 10
 {
11
-    public abstract class LuCrudBusiness<TDataAccess, TDboCreate, TDboRead, TDboUpdate> : LuBusiness, ILuCrudInterface<TDboCreate, TDboRead, TDboUpdate>
12
-        where TDataAccess : ILuCrudInterface<TDboCreate, TDboRead, TDboUpdate>
11
+    public abstract class LuCrudBusiness<TDataAccess, TDboCreate, TDboRead, TDboUpdate, TId> :
12
+            LuBusiness,
13
+            ILuCrudInterface<TDboCreate, TDboRead, TDboUpdate, TId>
14
+        where TDataAccess : ILuCrudInterface<TDboCreate, TDboRead, TDboUpdate, TId>
13 15
         where TDboCreate : class
14 16
         where TDboRead : class
15 17
         where TDboUpdate : class
@@ -46,7 +48,7 @@ namespace Luticate2.Utils.Business
46 48
             return LuResult<TDboUpdate>.Ok(update);
47 49
         }
48 50
 
49
-        protected LuResult<TDboUpdate> GetAndCheckEdit(string id, TDboUpdate update)
51
+        protected LuResult<TDboUpdate> GetAndCheckEdit(TId id, TDboUpdate update)
50 52
         {
51 53
             var res = GetSingleById(id);
52 54
             if (!res)
@@ -56,20 +58,10 @@ namespace Luticate2.Utils.Business
56 58
             return CheckEdit(res.Data, update);
57 59
         }
58 60
 
59
-        protected LuResult<TDboUpdate> GetAndCheckEdit(long id, TDboUpdate update)
60
-        {
61
-            var res = GetSingleById(id);
62
-            if (!res)
63
-            {
64
-                return res.To<TDboUpdate>();
65
-            }
66
-            return CheckEdit(res.Data, update);
67
-        }
68 61
 
69 62
 
70 63
 
71
-
72
-        public LuResult<T> Add<T>(IEnumerable<TDboCreate> objs, Func<IEnumerable<TDboRead>, T> returnFunc)
64
+        public virtual LuResult<T> Add<T>(IEnumerable<TDboCreate> objs, Func<IEnumerable<TDboRead>, T> returnFunc)
73 65
         {
74 66
             var res = CheckAdd(objs);
75 67
             if (!res)
@@ -79,7 +71,7 @@ namespace Luticate2.Utils.Business
79 71
             return DataAccess.Add(res.Data, returnFunc);
80 72
         }
81 73
 
82
-        public LuResult<T> Add<T>(TDboCreate obj, Func<TDboRead, T> returnFunc)
74
+        public virtual LuResult<T> Add<T>(TDboCreate obj, Func<TDboRead, T> returnFunc)
83 75
         {
84 76
             var res = CheckAdd(obj);
85 77
             if (!res)
@@ -89,47 +81,27 @@ namespace Luticate2.Utils.Business
89 81
             return DataAccess.Add(res.Data, returnFunc);
90 82
         }
91 83
 
92
-        public LuResult<IEnumerable<string>> AddGuid(IEnumerable<TDboCreate> objs)
84
+        public virtual LuResult<IEnumerable<TId>> AddId(IEnumerable<TDboCreate> objs)
93 85
         {
94 86
             var res = CheckAdd(objs);
95 87
             if (!res)
96 88
             {
97
-                return res.To<IEnumerable<string>>();
98
-            }
99
-            return DataAccess.AddGuid(res.Data);
100
-        }
101
-
102
-        public LuResult<string> AddGuid(TDboCreate obj)
103
-        {
104
-            var res = CheckAdd(obj);
105
-            if (!res)
106
-            {
107
-                return res.To<string>();
108
-            }
109
-            return DataAccess.AddGuid(res.Data);
110
-        }
111
-
112
-        public LuResult<IEnumerable<long>> AddId(IEnumerable<TDboCreate> obj)
113
-        {
114
-            var res = CheckAdd(obj);
115
-            if (!res)
116
-            {
117
-                return res.To<IEnumerable<long>>();
89
+                return res.To<IEnumerable<TId>>();
118 90
             }
119 91
             return DataAccess.AddId(res.Data);
120 92
         }
121 93
 
122
-        public LuResult<long> AddId(TDboCreate obj)
94
+        public virtual LuResult<TId> AddId(TDboCreate obj)
123 95
         {
124 96
             var res = CheckAdd(obj);
125 97
             if (!res)
126 98
             {
127
-                return res.To<long>();
99
+                return res.To<TId>();
128 100
             }
129 101
             return DataAccess.AddId(res.Data);
130 102
         }
131 103
 
132
-        public LuResult<IEnumerable<TDboRead>> AddDbo(IEnumerable<TDboCreate> obj)
104
+        public virtual LuResult<IEnumerable<TDboRead>> AddDbo(IEnumerable<TDboCreate> obj)
133 105
         {
134 106
             var res = CheckAdd(obj);
135 107
             if (!res)
@@ -139,7 +111,7 @@ namespace Luticate2.Utils.Business
139 111
             return DataAccess.AddDbo(res.Data);
140 112
         }
141 113
 
142
-        public LuResult<TDboRead> AddDbo(TDboCreate obj)
114
+        public virtual LuResult<TDboRead> AddDbo(TDboCreate obj)
143 115
         {
144 116
             var res = CheckAdd(obj);
145 117
             if (!res)
@@ -152,24 +124,19 @@ namespace Luticate2.Utils.Business
152 124
 
153 125
 
154 126
 
155
-        public LuResult<TDboRead> GetSingleById(string id)
127
+        public virtual LuResult<TDboRead> GetSingleById(TId id)
156 128
         {
157 129
             return DataAccess.GetSingleById(id);
158 130
         }
159 131
 
160
-        public LuResult<TDboRead> GetSingleById(long id)
161
-        {
162
-            return DataAccess.GetSingleById(id);
163
-        }
164 132
 
165
-
166
-        public LuResult<LuPaginatedDbo<TDboRead>> GetMultiple(LuOrderByDbo orderBy, LuFilterDbo filter,
133
+        public virtual LuResult<LuPaginatedDbo<TDboRead>> GetMultiple(LuOrderByDbo orderBy, LuFilterDbo filter,
167 134
             int page = 0, int perPage = int.MaxValue)
168 135
         {
169 136
             return DataAccess.GetMultiple(orderBy, filter, page, perPage);
170 137
         }
171 138
 
172
-        public LuResult<LuPaginatedDbo<TDboRead>> GetMultiple(LuOrderByDbo orderBy, int page = 0,
139
+        public virtual LuResult<LuPaginatedDbo<TDboRead>> GetMultiple(LuOrderByDbo orderBy, int page = 0,
173 140
             int perPage = int.MaxValue)
174 141
         {
175 142
             return DataAccess.GetMultiple(orderBy, page, perPage);
@@ -178,7 +145,7 @@ namespace Luticate2.Utils.Business
178 145
 
179 146
 
180 147
 
181
-        public LuResult<T> EditSingleById<T>(long id, TDboUpdate update, Func<TDboRead, T> returnFunc)
148
+        public virtual LuResult<T> EditSingleById<T>(TId id, TDboUpdate update, Func<TDboRead, T> returnFunc)
182 149
         {
183 150
             var obj = GetAndCheckEdit(id, update);
184 151
             if (!obj)
@@ -188,87 +155,42 @@ namespace Luticate2.Utils.Business
188 155
             return DataAccess.EditSingleById(id, obj.Data, returnFunc);
189 156
         }
190 157
 
191
-        public LuResult<long> EditSingleByIdId(long id, TDboUpdate update)
158
+        public virtual LuResult<TId> EditSingleByIdId(TId id, TDboUpdate update)
192 159
         {
193 160
             var obj = GetAndCheckEdit(id, update);
194 161
             if (!obj)
195 162
             {
196
-                return obj.To<long>();
163
+                return obj.To<TId>();
197 164
             }
198
-            return DataAccess.EditSingleByIdId(id, obj.Data);
165
+            return EditSingleById(id, obj.Data, read => (TId)((dynamic)read).Id);
199 166
         }
200 167
 
201
-        public LuResult<TDboRead> EditSingleByIdDbo(long id, TDboUpdate update)
168
+        public virtual LuResult<TDboRead> EditSingleByIdDbo(TId id, TDboUpdate update)
202 169
         {
203 170
             var obj = GetAndCheckEdit(id, update);
204 171
             if (!obj)
205 172
             {
206 173
                 return obj.To<TDboRead>();
207 174
             }
208
-            return DataAccess.EditSingleByIdDbo(id, obj.Data);
175
+            return EditSingleById(id, obj.Data, read => read);
209 176
         }
210 177
 
211
-        public LuResult<T> EditSingleById<T>(string id, TDboUpdate update, Func<TDboRead, T> returnFunc)
212
-        {
213
-            var obj = GetAndCheckEdit(id, update);
214
-            if (!obj)
215
-            {
216
-                return obj.To<T>();
217
-            }
218
-            return DataAccess.EditSingleById(id, obj.Data, returnFunc);
219
-        }
220
-
221
-        public LuResult<string> EditSingleByIdGuid(string id, TDboUpdate update)
222
-        {
223
-            var obj = GetAndCheckEdit(id, update);
224
-            if (!obj)
225
-            {
226
-                return obj.To<string>();
227
-            }
228
-            return DataAccess.EditSingleByIdGuid(id, obj.Data);
229
-        }
230
-
231
-        public LuResult<TDboRead> EditSingleByIdDbo(string id, TDboUpdate update)
232
-        {
233
-            var obj = GetAndCheckEdit(id, update);
234
-            if (!obj)
235
-            {
236
-                return obj.To<TDboRead>();
237
-            }
238
-            return DataAccess.EditSingleByIdDbo(id, obj.Data);
239
-        }
240 178
 
241 179
 
242 180
 
243
-
244
-        public LuResult<T> DeleteSingleById<T>(string id, Func<TDboRead, T> returnFunc)
245
-        {
246
-            return DataAccess.DeleteSingleById(id, returnFunc);
247
-        }
248
-
249
-        public LuResult<string> DeleteSingleByIdGuid(string id)
250
-        {
251
-            return DataAccess.DeleteSingleByIdGuid(id);
252
-        }
253
-
254
-        public LuResult<TDboRead> DeleteSingleByIdDbo(string id)
255
-        {
256
-            return DataAccess.DeleteSingleByIdDbo(id);
257
-        }
258
-
259
-        public LuResult<T> DeleteSingleById<T>(long id, Func<TDboRead, T> returnFunc)
181
+        public virtual LuResult<T> DeleteSingleById<T>(TId id, Func<TDboRead, T> returnFunc)
260 182
         {
261 183
             return DataAccess.DeleteSingleById(id, returnFunc);
262 184
         }
263 185
 
264
-        public LuResult<long> DeleteSingleByIdId(long id)
186
+        public virtual LuResult<TId> DeleteSingleByIdId(TId id)
265 187
         {
266
-            return DataAccess.DeleteSingleByIdId(id);
188
+            return DeleteSingleById(id, read => (TId)((dynamic)read).Id);
267 189
         }
268 190
 
269
-        public LuResult<TDboRead> DeleteSingleByIdDbo(long id)
191
+        public virtual LuResult<TDboRead> DeleteSingleByIdDbo(TId id)
270 192
         {
271
-            return DataAccess.DeleteSingleByIdDbo(id);
193
+            return DeleteSingleById(id, read => read);
272 194
         }
273 195
     }
274 196
 }

+ 26
- 0
Luticate2.Utils/Business/NotificationsBusiness.cs View File

@@ -0,0 +1,26 @@
1
+using Luticate2.Utils.Hubs;
2
+using Microsoft.AspNetCore.SignalR;
3
+using Microsoft.AspNetCore.SignalR.Infrastructure;
4
+
5
+namespace Luticate2.Utils.Business
6
+{
7
+    public class LuNotificationsBusiness
8
+    {
9
+        private readonly IHubContext _hubContext;
10
+
11
+        public LuNotificationsBusiness(IConnectionManager connectionManager)
12
+        {
13
+            _hubContext = connectionManager.GetHubContext<LuNotificationsHub>();
14
+        }
15
+
16
+        public void Notify(string eventName, string entityType, object entity)
17
+        {
18
+            _hubContext.Clients.All.notify(eventName, entityType, entity);
19
+        }
20
+
21
+        public void NotifyUpdate(string eventName, string entityType, object entity)
22
+        {
23
+            Notify("update", entityType, entity);
24
+        }
25
+    }
26
+}

+ 5
- 5
Luticate2.Utils/Controllers/LuCrudController.cs View File

@@ -9,11 +9,11 @@ using Microsoft.AspNetCore.Mvc;
9 9
 
10 10
 namespace Luticate2.Utils.Controllers
11 11
 {
12
-    public abstract class LuCrudController<TBusiness, TDboCreate, TDboRead, TDboUpdate> : LuController
12
+    public abstract class LuCrudController<TBusiness, TDboCreate, TDboRead, TDboUpdate, TId> : LuController
13 13
         where TDboCreate : class
14 14
         where TDboRead : class
15 15
         where TDboUpdate : class
16
-        where TBusiness : ILuCrudInterface<TDboCreate, TDboRead, TDboUpdate>
16
+        where TBusiness : ILuCrudInterface<TDboCreate, TDboRead, TDboUpdate, TId>
17 17
     {
18 18
         protected readonly TBusiness Busines;
19 19
 
@@ -24,7 +24,7 @@ namespace Luticate2.Utils.Controllers
24 24
 
25 25
         [HttpGet]
26 26
         [Route("[controller]/{id}")]
27
-        public LuApiWrapperDbo<TDboRead> GetSingleById(string id)
27
+        public LuApiWrapperDbo<TDboRead> GetSingleById(TId id)
28 28
         {
29 29
             return Handle(Busines.GetSingleById(id));
30 30
         }
@@ -46,14 +46,14 @@ namespace Luticate2.Utils.Controllers
46 46
 
47 47
         [HttpPost]
48 48
         [Route("[controller]/{id}")]
49
-        public LuApiWrapperDbo<TDboRead> EditSingleByIdDbo(string id, [FromBody]TDboUpdate data)
49
+        public LuApiWrapperDbo<TDboRead> EditSingleByIdDbo(TId id, [FromBody]TDboUpdate data)
50 50
         {
51 51
             return Handle(Busines.EditSingleByIdDbo(id, data));
52 52
         }
53 53
 
54 54
         [HttpDelete]
55 55
         [Route("[controller]/{id}")]
56
-        public LuApiWrapperDbo<TDboRead> Delete(string id)
56
+        public LuApiWrapperDbo<TDboRead> Delete(TId id)
57 57
         {
58 58
             return Handle(Busines.DeleteSingleByIdDbo(id));
59 59
         }

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

@@ -1,4 +1,5 @@
1 1
 using System.Collections.Generic;
2
+using Luticate2.Utils.Business;
2 3
 using Luticate2.Utils.DataAccess.Npgsql;
3 4
 using Luticate2.Utils.Dbo.Basic;
4 5
 using Luticate2.Utils.Dbo.Filter;
@@ -22,8 +23,13 @@ namespace Luticate2.Utils.Controllers
22 23
 
23 24
         public static IServiceCollection AddLuticateUtils(this IServiceCollection services, LuOptionsDelegate optionsDelegate)
24 25
         {
26
+            services.AddSingleton<LuNotificationsBusiness>();
25 27
             Options = new LuOptionsDbo();
26 28
             optionsDelegate(Options);
29
+            services.AddSignalR(options =>
30
+            {
31
+                options.Hubs.EnableDetailedErrors = true;
32
+            });
27 33
             return services;
28 34
         }
29 35
 
@@ -48,6 +54,10 @@ namespace Luticate2.Utils.Controllers
48 54
         public static IApplicationBuilder UseLuticateUtils(this IApplicationBuilder app)
49 55
         {
50 56
             app.UseMiddleware<LuExceptionMiddleware>();
57
+
58
+            app.UseWebSockets();
59
+            app.UseSignalR();
60
+
51 61
             return app;
52 62
         }
53 63
 

+ 47
- 121
Luticate2.Utils/DataAccess/LuEfCrudDataAccess.cs View File

@@ -2,7 +2,6 @@
2 2
 using System.Collections.Generic;
3 3
 using System.Linq;
4 4
 using System.Linq.Expressions;
5
-using Luticate2.Utils.DataAccess.Npgsql;
6 5
 using Luticate2.Utils.Dbo.Basic;
7 6
 using Luticate2.Utils.Dbo.Filter;
8 7
 using Luticate2.Utils.Dbo.OrderBy;
@@ -10,11 +9,13 @@ using Luticate2.Utils.Dbo.Result;
10 9
 using Luticate2.Utils.Interfaces;
11 10
 using Luticate2.Utils.Utils;
12 11
 using Microsoft.EntityFrameworkCore;
12
+using Microsoft.EntityFrameworkCore.Metadata.Internal;
13 13
 
14 14
 namespace Luticate2.Utils.DataAccess
15 15
 {
16
-    public abstract class LuEfCrudDataAccess<TModel, TDboCreate, TDboRead, TDboUpdate, TDbContext> :
17
-            LuEfDataAccess<TModel, TDbContext>, ILuCrudInterface<TDboCreate, TDboRead, TDboUpdate>
16
+    public abstract class LuEfCrudDataAccess<TModel, TDboCreate, TDboRead, TDboUpdate, TDbContext, TId> :
17
+            LuEfDataAccess<TModel, TDbContext>,
18
+            ILuCrudInterface<TDboCreate, TDboRead, TDboUpdate, TId>
18 19
         where TModel : class
19 20
         where TDboCreate : class
20 21
         where TDboRead : class
@@ -61,14 +62,20 @@ namespace Luticate2.Utils.DataAccess
61 62
             return model;
62 63
         }
63 64
 
64
-        protected Guid? GetGuid(string id)
65
+        protected virtual object GetId(TId id)
65 66
         {
66
-            Guid guid;
67
-            if (Guid.TryParse(id, out guid))
67
+            var s = id as string;
68
+            if (s != null)
68 69
             {
69
-                return guid;
70
+                Guid guid;
71
+                if (Guid.TryParse(s, out guid))
72
+                {
73
+                    return guid;
74
+                }
75
+                return null;
76
+
70 77
             }
71
-            return null;
78
+            return id;
72 79
         }
73 80
 
74 81
         protected LuResult<T> GetNotFoundResult<T>()
@@ -103,25 +110,13 @@ namespace Luticate2.Utils.DataAccess
103 110
         }
104 111
 
105 112
 
106
-        public LuResult<IEnumerable<string>> AddGuid(IEnumerable<TDboCreate> objs)
113
+        public LuResult<IEnumerable<TId>> AddId(IEnumerable<TDboCreate> objs)
107 114
         {
108
-            var func = GetIdFunc<string>();
115
+            var func = GetIdFunc<TId>();
109 116
             return Add(objs, list => list.Select(func));
110 117
         }
111 118
 
112
-        public LuResult<string> AddGuid(TDboCreate obj)
113
-        {
114
-            return AddGuid(new List<TDboCreate> {obj}).To(list => list.First());
115
-        }
116
-
117
-
118
-        public LuResult<IEnumerable<long>> AddId(IEnumerable<TDboCreate> obj)
119
-        {
120
-            var func = GetIdFunc<long>();
121
-            return Add(obj, list => list.Select(func));
122
-        }
123
-
124
-        public LuResult<long> AddId(TDboCreate obj)
119
+        public LuResult<TId> AddId(TDboCreate obj)
125 120
         {
126 121
             return AddId(new List<TDboCreate> {obj}).To(list => list.First());
127 122
         }
@@ -159,9 +154,9 @@ namespace Luticate2.Utils.DataAccess
159 154
             return GetSingle(GetExpression(keys));
160 155
         }
161 156
 
162
-        public LuResult<TDboRead> GetSingleById(string id)
157
+        public LuResult<TDboRead> GetSingleById(TId id)
163 158
         {
164
-            var guid = GetGuid(id);
159
+            var guid = GetId(id);
165 160
             if (guid == null)
166 161
             {
167 162
                 return GetNotFoundResult<TDboRead>();
@@ -169,11 +164,6 @@ namespace Luticate2.Utils.DataAccess
169 164
             return GetSingleByKeys(new KeyValuePair<string, object>("id", guid));
170 165
         }
171 166
 
172
-        public LuResult<TDboRead> GetSingleById(long id)
173
-        {
174
-            return GetSingleByKeys(new KeyValuePair<string, object>("id", id));
175
-        }
176
-
177 167
 
178 168
         public LuResult<LuPaginatedDbo<TDboRead>> GetMultiple(Func<DbSet<TModel>, IOrderedQueryable<TModel>> orderBy,
179 169
             Expression<Func<TModel, bool>> predicate, int page = 0, int perPage = int.MaxValue,
@@ -218,12 +208,11 @@ namespace Luticate2.Utils.DataAccess
218 208
             return GetMultiple(orderBy, x => true, page, perPage, otherOrderBy);
219 209
         }
220 210
 
221
-        public LuResult<LuPaginatedDbo<TDboRead>> GetMultiple(LuOrderByDbo orderBy, LuFilterDbo filter,
211
+        public LuResult<LuPaginatedDbo<TDboRead>> GetMultiple(LuOrderByDbo orderBy, IQueryable<TModel> queryable,
222 212
             int page = 0, int perPage = int.MaxValue)
223 213
         {
224 214
             return Execute(() =>
225 215
             {
226
-                var queryable = GetFilterQuery(filter);
227 216
                 var count = queryable.Count();
228 217
                 IOrderedQueryable<TModel> ordered = null;
229 218
                 foreach (var field in orderBy.Fields)
@@ -254,13 +243,15 @@ namespace Luticate2.Utils.DataAccess
254 243
             });
255 244
         }
256 245
 
246
+        public LuResult<LuPaginatedDbo<TDboRead>> GetMultiple(LuOrderByDbo orderBy, LuFilterDbo filter,
247
+            int page = 0, int perPage = int.MaxValue)
248
+        {
249
+            return GetMultiple(orderBy, GetFilterQuery(filter), page, perPage);
250
+        }
251
+
257 252
         public LuResult<LuPaginatedDbo<TDboRead>> GetMultiple(LuOrderByDbo orderBy, int page = 0, int perPage = int.MaxValue)
258 253
         {
259
-            var filter = new LuFilterDbo
260
-            {
261
-                Query = ""
262
-            };
263
-            return GetMultiple(orderBy, filter, page, perPage);
254
+            return GetMultiple(orderBy, Table, page, perPage);
264 255
         }
265 256
 
266 257
 
@@ -284,15 +275,9 @@ namespace Luticate2.Utils.DataAccess
284 275
             });
285 276
         }
286 277
 
287
-        public LuResult<IEnumerable<string>> EditGuid(Expression<Func<TModel, bool>> predicate, Action<TModel> update)
288
-        {
289
-            var func = GetIdFunc<string>();
290
-            return Edit(predicate, update, reads => reads.Select(func));
291
-        }
292
-
293
-        public LuResult<IEnumerable<long>> EditId(Expression<Func<TModel, bool>> predicate, Action<TModel> update)
278
+        public LuResult<IEnumerable<TId>> EditId(Expression<Func<TModel, bool>> predicate, Action<TModel> update)
294 279
         {
295
-            var func = GetIdFunc<long>();
280
+            var func = GetIdFunc<TId>();
296 281
             return Edit(predicate, update, reads => reads.Select(func));
297 282
         }
298 283
 
@@ -302,27 +287,9 @@ namespace Luticate2.Utils.DataAccess
302 287
         }
303 288
 
304 289
 
305
-        public LuResult<T> EditSingleById<T>(long id, Action<TModel> update, Func<TDboRead, T> returnFunc)
290
+        public LuResult<T> EditSingleById<T>(TId id, Action<TModel> update, Func<TDboRead, T> returnFunc)
306 291
         {
307
-            return Edit(GetExpression(new KeyValuePair<string, object>("id", id)), update,
308
-                list => returnFunc(list.FirstOrDefault()));
309
-        }
310
-
311
-        public LuResult<long> EditSingleByIdId(long id, Action<TModel> update)
312
-        {
313
-            var func = GetIdFunc<long>();
314
-            return EditSingleById(id, update, func);
315
-        }
316
-
317
-        public LuResult<TDboRead> EditSingleByIdDbo(long id, Action<TModel> update)
318
-        {
319
-            return EditSingleById(id, update, read => read);
320
-        }
321
-
322
-
323
-        public LuResult<T> EditSingleById<T>(string id, Action<TModel> update, Func<TDboRead, T> returnFunc)
324
-        {
325
-            var guid = GetGuid(id);
292
+            var guid = GetId(id);
326 293
             if (guid == null)
327 294
             {
328 295
                 return GetNotFoundResult<T>();
@@ -331,37 +298,20 @@ namespace Luticate2.Utils.DataAccess
331 298
                 list => returnFunc(list.FirstOrDefault()));
332 299
         }
333 300
 
334
-        public LuResult<string> EditSingleByIdGuid(string id, Action<TModel> update)
335
-        {
336
-            return EditSingleById(id, update, GetIdFunc<string>());
337
-        }
338
-
339
-        public LuResult<TDboRead> EditSingleByIdDbo(string id, Action<TModel> update)
340
-        {
341
-            return EditSingleById(id, update, read => read);
342
-        }
343
-
344
-
345
-        public LuResult<T> EditSingleById<T>(long id, TDboUpdate update, Func<TDboRead, T> returnFunc)
346
-        {
347
-            return Edit(GetExpression(new KeyValuePair<string, object>("id", id)),
348
-                model => EditModelFromTUpdate(update, model), list => returnFunc(list.FirstOrDefault()));
349
-        }
350
-
351
-        public LuResult<long> EditSingleByIdId(long id, TDboUpdate update)
301
+        public LuResult<TId> EditSingleByIdId(TId id, Action<TModel> update)
352 302
         {
353
-            return EditSingleById(id, update, GetIdFunc<long>());
303
+            return EditSingleById(id, update, GetIdFunc<TId>());
354 304
         }
355 305
 
356
-        public LuResult<TDboRead> EditSingleByIdDbo(long id, TDboUpdate update)
306
+        public LuResult<TDboRead> EditSingleByIdDbo(TId id, Action<TModel> update)
357 307
         {
358 308
             return EditSingleById(id, update, read => read);
359 309
         }
360 310
 
361 311
 
362
-        public LuResult<T> EditSingleById<T>(string id, TDboUpdate update, Func<TDboRead, T> returnFunc)
312
+        public LuResult<T> EditSingleById<T>(TId id, TDboUpdate update, Func<TDboRead, T> returnFunc)
363 313
         {
364
-            var guid = GetGuid(id);
314
+            var guid = GetId(id);
365 315
             if (guid == null)
366 316
             {
367 317
                 return GetNotFoundResult<T>();
@@ -370,12 +320,12 @@ namespace Luticate2.Utils.DataAccess
370 320
                 model => EditModelFromTUpdate(update, model), list => returnFunc(list.FirstOrDefault()));
371 321
         }
372 322
 
373
-        public LuResult<string> EditSingleByIdGuid(string id, TDboUpdate update)
323
+        public LuResult<TId> EditSingleByIdId(TId id, TDboUpdate update)
374 324
         {
375
-            return EditSingleById(id, update, GetIdFunc<string>());
325
+            return EditSingleById(id, update, GetIdFunc<TId>());
376 326
         }
377 327
 
378
-        public LuResult<TDboRead> EditSingleByIdDbo(string id, TDboUpdate update)
328
+        public LuResult<TDboRead> EditSingleByIdDbo(TId id, TDboUpdate update)
379 329
         {
380 330
             return EditSingleById(id, update, read => read);
381 331
         }
@@ -396,15 +346,9 @@ namespace Luticate2.Utils.DataAccess
396 346
             });
397 347
         }
398 348
 
399
-        public LuResult<IEnumerable<string>> DeleteGuid(Expression<Func<TModel, bool>> predicate)
349
+        public LuResult<IEnumerable<TId>> DeleteId(Expression<Func<TModel, bool>> predicate)
400 350
         {
401
-            var func = GetIdFunc<string>();
402
-            return Delete(predicate, reads => reads.Select(func));
403
-        }
404
-
405
-        public LuResult<IEnumerable<long>> DeleteId(Expression<Func<TModel, bool>> predicate)
406
-        {
407
-            var func = GetIdFunc<long>();
351
+            var func = GetIdFunc<TId>();
408 352
             return Delete(predicate, reads => reads.Select(func));
409 353
         }
410 354
 
@@ -414,9 +358,9 @@ namespace Luticate2.Utils.DataAccess
414 358
         }
415 359
 
416 360
 
417
-        public LuResult<T> DeleteSingleById<T>(string id, Func<TDboRead, T> returnFunc)
361
+        public LuResult<T> DeleteSingleById<T>(TId id, Func<TDboRead, T> returnFunc)
418 362
         {
419
-            var guid = GetGuid(id);
363
+            var guid = GetId(id);
420 364
             if (guid == null)
421 365
             {
422 366
                 return GetNotFoundResult<T>();
@@ -425,31 +369,13 @@ namespace Luticate2.Utils.DataAccess
425 369
                 reads => returnFunc(reads.FirstOrDefault()));
426 370
         }
427 371
 
428
-        public LuResult<string> DeleteSingleByIdGuid(string id)
429
-        {
430
-            var func = GetIdFunc<string>();
431
-            return DeleteSingleById(id, func);
432
-        }
433
-
434
-        public LuResult<TDboRead> DeleteSingleByIdDbo(string id)
435
-        {
436
-            return DeleteSingleById(id, read => read);
437
-        }
438
-
439
-
440
-        public LuResult<T> DeleteSingleById<T>(long id, Func<TDboRead, T> returnFunc)
441
-        {
442
-            return Delete(GetExpression(new KeyValuePair<string, object>("id", id)),
443
-                reads => returnFunc(reads.First()));
444
-        }
445
-
446
-        public LuResult<long> DeleteSingleByIdId(long id)
372
+        public LuResult<TId> DeleteSingleByIdId(TId id)
447 373
         {
448
-            var func = GetIdFunc<long>();
374
+            var func = GetIdFunc<TId>();
449 375
             return DeleteSingleById(id, func);
450 376
         }
451 377
 
452
-        public LuResult<TDboRead> DeleteSingleByIdDbo(long id)
378
+        public LuResult<TDboRead> DeleteSingleByIdDbo(TId id)
453 379
         {
454 380
             return DeleteSingleById(id, read => read);
455 381
         }

+ 9
- 0
Luticate2.Utils/Hubs/LuNotificationsHub.cs View File

@@ -0,0 +1,9 @@
1
+using Microsoft.AspNetCore.SignalR;
2
+
3
+namespace Luticate2.Utils.Hubs
4
+{
5
+    public class LuNotificationsHub : Hub
6
+    {
7
+
8
+    }
9
+}

+ 10
- 31
Luticate2.Utils/Interfaces/ILuCrudInterface.cs View File

@@ -8,7 +8,7 @@ using Luticate2.Utils.Dbo.Result;
8 8
 
9 9
 namespace Luticate2.Utils.Interfaces
10 10
 {
11
-    public interface ILuCrudInterface<TDboCreate, TDboRead, TDboUpdate>
11
+    public interface ILuCrudInterface<TDboCreate, TDboRead, TDboUpdate, TId>
12 12
         where TDboCreate : class
13 13
         where TDboRead : class
14 14
         where TDboUpdate : class
@@ -18,14 +18,9 @@ namespace Luticate2.Utils.Interfaces
18 18
         LuResult<T> Add<T>(TDboCreate obj, Func<TDboRead, T> returnFunc);
19 19
 
20 20
 
21
-        LuResult<IEnumerable<string>> AddGuid(IEnumerable<TDboCreate> objs);
21
+        LuResult<IEnumerable<TId>> AddId(IEnumerable<TDboCreate> objs);
22 22
 
23
-        LuResult<string> AddGuid(TDboCreate obj);
24
-
25
-
26
-        LuResult<IEnumerable<long>> AddId(IEnumerable<TDboCreate> obj);
27
-
28
-        LuResult<long> AddId(TDboCreate obj);
23
+        LuResult<TId> AddId(TDboCreate obj);
29 24
 
30 25
         LuResult<IEnumerable<TDboRead>> AddDbo(IEnumerable<TDboCreate> obj);
31 26
 
@@ -34,9 +29,7 @@ namespace Luticate2.Utils.Interfaces
34 29
 
35 30
 
36 31
 
37
-        LuResult<TDboRead> GetSingleById(string id);
38
-
39
-        LuResult<TDboRead> GetSingleById(long id);
32
+        LuResult<TDboRead> GetSingleById(TId id);
40 33
 
41 34
 
42 35
         LuResult<LuPaginatedDbo<TDboRead>> GetMultiple(LuOrderByDbo orderBy, LuFilterDbo filter,
@@ -47,33 +40,19 @@ namespace Luticate2.Utils.Interfaces
47 40
 
48 41
 
49 42
 
50
-        LuResult<T> EditSingleById<T>(long id, TDboUpdate update, Func<TDboRead, T> returnFunc);
51
-
52
-        LuResult<long> EditSingleByIdId(long id, TDboUpdate update);
53
-
54
-        LuResult<TDboRead> EditSingleByIdDbo(long id, TDboUpdate update);
55
-
56
-
57
-        LuResult<T> EditSingleById<T>(string id, TDboUpdate update, Func<TDboRead, T> returnFunc);
58
-
59
-        LuResult<string> EditSingleByIdGuid(string id, TDboUpdate update);
60
-
61
-        LuResult<TDboRead> EditSingleByIdDbo(string id, TDboUpdate update);
62
-
63
-
43
+        LuResult<T> EditSingleById<T>(TId id, TDboUpdate update, Func<TDboRead, T> returnFunc);
64 44
 
45
+        LuResult<TId> EditSingleByIdId(TId id, TDboUpdate update);
65 46
 
66
-        LuResult<T> DeleteSingleById<T>(string id, Func<TDboRead, T> returnFunc);
47
+        LuResult<TDboRead> EditSingleByIdDbo(TId id, TDboUpdate update);
67 48
 
68
-        LuResult<string> DeleteSingleByIdGuid(string id);
69 49
 
70
-        LuResult<TDboRead> DeleteSingleByIdDbo(string id);
71 50
 
72 51
 
73
-        LuResult<T> DeleteSingleById<T>(long id, Func<TDboRead, T> returnFunc);
52
+        LuResult<T> DeleteSingleById<T>(TId id, Func<TDboRead, T> returnFunc);
74 53
 
75
-        LuResult<long> DeleteSingleByIdId(long id);
54
+        LuResult<TId> DeleteSingleByIdId(TId id);
76 55
 
77
-        LuResult<TDboRead> DeleteSingleByIdDbo(long id);
56
+        LuResult<TDboRead> DeleteSingleByIdDbo(TId id);
78 57
     }
79 58
 }

+ 0
- 3
TODO View File

@@ -1,8 +1,5 @@
1
-fix crud business checks
2 1
 websockets
3 2
 authentication filter
4
-filter dbo
5
-try to generify long/string id
6 3
 logs
7 4
 log exceptions in middleware
8 5
 LuCrudBusiness check user?

+ 1
- 1
Test/Utils/DataAccess/LuUtilsPkBigSerialDataAccess.cs View File

@@ -7,7 +7,7 @@ using Test.Utils.Dbo.PkBigSerial;
7 7
 
8 8
 namespace Test.Utils.DataAccess
9 9
 {
10
-    public class LuUtilsPkBigSerialDataAccess : LuEfCrudDataAccess<pk_bigserial, PkBigSerialAddDbo, PkBigSerialDbo, PkBigSerialAddDbo, LuUtilsDbContext>
10
+    public class LuUtilsPkBigSerialDataAccess : LuEfCrudDataAccess<pk_bigserial, PkBigSerialAddDbo, PkBigSerialDbo, PkBigSerialAddDbo, LuUtilsDbContext, long>
11 11
     {
12 12
         public LuUtilsPkBigSerialDataAccess(LuUtilsDbContext db) : base(db, db.pk_bigserial)
13 13
         {

+ 1
- 2
Test/Utils/DataAccess/LuUtilsPkGuidDataAccess.cs View File

@@ -2,13 +2,12 @@
2 2
 using System.Linq.Expressions;
3 3
 using Luticate2.Utils.DataAccess;
4 4
 using Luticate2.Utils.Dbo.Filter;
5
-using Luticate2.Utils.Utils;
6 5
 using Test.Utils.DataAccess.Models;
7 6
 using Test.Utils.Dbo.PkGuid;
8 7
 
9 8
 namespace Test.Utils.DataAccess
10 9
 {
11
-    public class LuUtilsPkGuidDataAccess : LuEfCrudDataAccess<pk_guid, PkGuidAddDbo, PkGuidDbo, PkGuidAddDbo, LuUtilsDbContext>
10
+    public class LuUtilsPkGuidDataAccess : LuEfCrudDataAccess<pk_guid, PkGuidAddDbo, PkGuidDbo, PkGuidAddDbo, LuUtilsDbContext, string>
12 11
     {
13 12
         public LuUtilsPkGuidDataAccess(LuUtilsDbContext db) : base(db, db.pk_guid)
14 13
         {

+ 2
- 2
Test/Utils/EfCrudDataAccess/LuEfCreateDataAccessTest.cs View File

@@ -222,7 +222,7 @@ namespace Test.Utils.EfCrubDataAccess
222 222
                     }
223 223
                 };
224 224
                 var service = new LuUtilsPkGuidDataAccess(context);
225
-                var res = service.AddGuid(dbos);
225
+                var res = service.AddId(dbos);
226 226
                 Assert.Equal(LuStatus.Success, res.Status);
227 227
                 foreach (var dbo in dbos.Zip(res.Data, (dbo, serialDbo) => new KeyValuePair<PkGuidAddDbo, string>(dbo, serialDbo)))
228 228
                 {
@@ -247,7 +247,7 @@ namespace Test.Utils.EfCrubDataAccess
247 247
             Tests.TestRealDb(context =>
248 248
             {
249 249
                 var service = new LuUtilsPkGuidDataAccess(context);
250
-                var res = service.AddGuid(new PkGuidAddDbo
250
+                var res = service.AddId(new PkGuidAddDbo
251 251
                 {
252 252
                     SomeInt = 42,
253 253
                     SomeText = "42"

+ 11
- 14
Test/Utils/EfCrudDataAccess/LuEfDeleteDataAccessTest.cs View File

@@ -1,15 +1,12 @@
1
-using System;
2
-using System.Collections.Generic;
1
+using System.Collections.Generic;
3 2
 using System.Linq;
4
-using Luticate2.Utils.Dbo;
5 3
 using Luticate2.Utils.Dbo.Result;
6 4
 using Test.Utils.DataAccess;
7 5
 using Test.Utils.Dbo.PkBigSerial;
8 6
 using Test.Utils.Dbo.PkGuid;
9 7
 using Xunit;
10 8
 
11
-
12
-namespace Test.Utils.EfCrubDataAccess
9
+namespace Test.Utils.EfCrudDataAccess
13 10
 {
14 11
     public class LuEfDeleteDataAccessTest
15 12
     {
@@ -37,7 +34,7 @@ namespace Test.Utils.EfCrubDataAccess
37 34
                     }
38 35
                 };
39 36
                 var service = new LuUtilsPkGuidDataAccess(context);
40
-                var res = service.AddGuid(dbos);
37
+                var res = service.AddId(dbos);
41 38
                 Assert.Equal(LuStatus.Success, res.Status);
42 39
 
43 40
                 var edit = service.Delete(guid => guid.some_int == 42, enumerable => enumerable);
@@ -88,7 +85,7 @@ namespace Test.Utils.EfCrubDataAccess
88 85
                     }
89 86
                 };
90 87
                 var service = new LuUtilsPkGuidDataAccess(context);
91
-                var res = service.AddGuid(dbos);
88
+                var res = service.AddId(dbos);
92 89
                 Assert.Equal(LuStatus.Success, res.Status);
93 90
 
94 91
                 var edit = service.Delete(guid => guid.some_int == 42, enumerable => enumerable.Select(guidDbo => guidDbo.Id));
@@ -131,10 +128,10 @@ namespace Test.Utils.EfCrubDataAccess
131 128
                     }
132 129
                 };
133 130
                 var service = new LuUtilsPkGuidDataAccess(context);
134
-                var res = service.AddGuid(dbos);
131
+                var res = service.AddId(dbos);
135 132
                 Assert.Equal(LuStatus.Success, res.Status);
136 133
 
137
-                var edit = service.DeleteGuid(guid => guid.some_int == 42);
134
+                var edit = service.DeleteId(guid => guid.some_int == 42);
138 135
 
139 136
                 Assert.Equal(LuStatus.Success, edit.Status);
140 137
                 var elements = edit.Data.ToList();
@@ -217,7 +214,7 @@ namespace Test.Utils.EfCrubDataAccess
217 214
                     }
218 215
                 };
219 216
                 var service = new LuUtilsPkGuidDataAccess(context);
220
-                var res = service.AddGuid(dbos);
217
+                var res = service.AddId(dbos);
221 218
                 Assert.Equal(LuStatus.Success, res.Status);
222 219
 
223 220
                 var edit = service.DeleteDbo(guid => guid.some_int == 42);
@@ -268,7 +265,7 @@ namespace Test.Utils.EfCrubDataAccess
268 265
                     }
269 266
                 };
270 267
                 var service = new LuUtilsPkGuidDataAccess(context);
271
-                var res = service.AddGuid(dbos);
268
+                var res = service.AddId(dbos);
272 269
                 Assert.Equal(LuStatus.Success, res.Status);
273 270
 
274 271
                 var ids = res.Data.ToList();
@@ -315,12 +312,12 @@ namespace Test.Utils.EfCrubDataAccess
315 312
                     }
316 313
                 };
317 314
                 var service = new LuUtilsPkGuidDataAccess(context);
318
-                var res = service.AddGuid(dbos);
315
+                var res = service.AddId(dbos);
319 316
                 Assert.Equal(LuStatus.Success, res.Status);
320 317
 
321 318
                 var ids = res.Data.ToList();
322 319
 
323
-                var edit = service.DeleteSingleByIdGuid(ids[0]);
320
+                var edit = service.DeleteSingleByIdId(ids[0]);
324 321
                 Assert.Equal(LuStatus.Success, edit.Status);
325 322
 
326 323
                 var get = service.GetMultiple(guid => guid.some_text);
@@ -360,7 +357,7 @@ namespace Test.Utils.EfCrubDataAccess
360 357
                     }
361 358
                 };
362 359
                 var service = new LuUtilsPkGuidDataAccess(context);
363
-                var res = service.AddGuid(dbos);
360
+                var res = service.AddId(dbos);
364 361
                 Assert.Equal(LuStatus.Success, res.Status);
365 362
 
366 363
                 var ids = res.Data.ToList();

+ 8
- 8
Test/Utils/EfCrudDataAccess/LuEfReadDataAccessTest.cs View File

@@ -143,7 +143,7 @@ namespace Test.Utils.EfCrudDataAccess
143 143
             Tests.TestRealDb(context =>
144 144
             {
145 145
                 var service = new LuUtilsPkGuidDataAccess(context);
146
-                var res = service.AddGuid(new PkGuidAddDbo
146
+                var res = service.AddId(new PkGuidAddDbo
147 147
                 {
148 148
                     SomeInt = 42,
149 149
                     SomeText = "42"
@@ -165,7 +165,7 @@ namespace Test.Utils.EfCrudDataAccess
165 165
             Tests.TestRealDb(context =>
166 166
             {
167 167
                 var service = new LuUtilsPkGuidDataAccess(context);
168
-                var res = service.AddGuid(new PkGuidAddDbo
168
+                var res = service.AddId(new PkGuidAddDbo
169 169
                 {
170 170
                     SomeInt = 42,
171 171
                     SomeText = "42"
@@ -202,7 +202,7 @@ namespace Test.Utils.EfCrudDataAccess
202 202
                     }
203 203
                 };
204 204
                 var service = new LuUtilsPkGuidDataAccess(context);
205
-                var res = service.AddGuid(dbos);
205
+                var res = service.AddId(dbos);
206 206
                 Assert.Equal(LuStatus.Success, res.Status);
207 207
 
208 208
                 var get = service.GetMultiple(table => table.OrderBy(guid => guid.some_int),
@@ -245,7 +245,7 @@ namespace Test.Utils.EfCrudDataAccess
245 245
                     }
246 246
                 };
247 247
                 var service = new LuUtilsPkGuidDataAccess(context);
248
-                var res = service.AddGuid(dbos);
248
+                var res = service.AddId(dbos);
249 249
                 Assert.Equal(LuStatus.Success, res.Status);
250 250
 
251 251
                 var get = service.GetMultiple(guid => guid.some_int, guid => guid.some_int == 42, 0, int.MaxValue,
@@ -288,7 +288,7 @@ namespace Test.Utils.EfCrudDataAccess
288 288
                     }
289 289
                 };
290 290
                 var service = new LuUtilsPkGuidDataAccess(context);
291
-                var res = service.AddGuid(dbos);
291
+                var res = service.AddId(dbos);
292 292
                 Assert.Equal(LuStatus.Success, res.Status);
293 293
 
294 294
                 var get = service.GetMultiple(table => table.OrderBy(guid => guid.some_int), 0, int.MaxValue,
@@ -335,7 +335,7 @@ namespace Test.Utils.EfCrudDataAccess
335 335
                     }
336 336
                 };
337 337
                 var service = new LuUtilsPkGuidDataAccess(context);
338
-                var res = service.AddGuid(dbos);
338
+                var res = service.AddId(dbos);
339 339
                 Assert.Equal(LuStatus.Success, res.Status);
340 340
 
341 341
                 var get = service.GetMultiple(guid => guid.some_int, 0, int.MaxValue, guid => guid.some_text);
@@ -381,7 +381,7 @@ namespace Test.Utils.EfCrudDataAccess
381 381
                     }
382 382
                 };
383 383
                 var service = new LuUtilsPkGuidDataAccess(context);
384
-                var res = service.AddGuid(dbos);
384
+                var res = service.AddId(dbos);
385 385
                 Assert.Equal(LuStatus.Success, res.Status);
386 386
 
387 387
                 var orderBy = LuOrderByBinder.FromString("someInt,someText");
@@ -430,7 +430,7 @@ namespace Test.Utils.EfCrudDataAccess
430 430
                     }
431 431
                 };
432 432
                 var service = new LuUtilsPkGuidDataAccess(context);
433
-                var res = service.AddGuid(dbos);
433
+                var res = service.AddId(dbos);
434 434
                 Assert.Equal(LuStatus.Success, res.Status);
435 435
 
436 436
                 var orderBy = LuOrderByBinder.FromString("someText:desc,someInt");

+ 14
- 15
Test/Utils/EfCrudDataAccess/LuEfUpdateDataAccessTest.cs View File

@@ -1,14 +1,13 @@
1 1
 using System;
2 2
 using System.Collections.Generic;
3 3
 using System.Linq;
4
-using Luticate2.Utils.Dbo;
5 4
 using Luticate2.Utils.Dbo.Result;
6 5
 using Test.Utils.DataAccess;
7 6
 using Test.Utils.Dbo.PkBigSerial;
8 7
 using Test.Utils.Dbo.PkGuid;
9 8
 using Xunit;
10 9
 
11
-namespace Test.Utils.EfCrubDataAccess
10
+namespace Test.Utils.EfCrudDataAccess
12 11
 {
13 12
     public class LuEfUpdateDataAccessTest
14 13
     {
@@ -36,7 +35,7 @@ namespace Test.Utils.EfCrubDataAccess
36 35
                     }
37 36
                 };
38 37
                 var service = new LuUtilsPkGuidDataAccess(context);
39
-                var res = service.AddGuid(dbos);
38
+                var res = service.AddId(dbos);
40 39
                 Assert.Equal(LuStatus.Success, res.Status);
41 40
 
42 41
                 var edit = service.Edit(guid => guid.some_int == 42, guid => guid.some_int = -1, enumerable => enumerable);
@@ -79,7 +78,7 @@ namespace Test.Utils.EfCrubDataAccess
79 78
                     }
80 79
                 };
81 80
                 var service = new LuUtilsPkGuidDataAccess(context);
82
-                var res = service.AddGuid(dbos);
81
+                var res = service.AddId(dbos);
83 82
                 Assert.Equal(LuStatus.Success, res.Status);
84 83
 
85 84
                 var edit = service.Edit(guid => guid.some_int == 42, guid => guid.some_int = -1, enumerable => enumerable.Select(guidDbo => guidDbo.SomeText));
@@ -120,10 +119,10 @@ namespace Test.Utils.EfCrubDataAccess
120 119
                     }
121 120
                 };
122 121
                 var service = new LuUtilsPkGuidDataAccess(context);
123
-                var res = service.AddGuid(dbos);
122
+                var res = service.AddId(dbos);
124 123
                 Assert.Equal(LuStatus.Success, res.Status);
125 124
 
126
-                var edit = service.EditGuid(guid => guid.some_int == 42, guid => guid.some_int = -1);
125
+                var edit = service.EditId(guid => guid.some_int == 42, guid => guid.some_int = -1);
127 126
 
128 127
                 Assert.Equal(LuStatus.Success, edit.Status);
129 128
                 var elements = edit.Data.ToList();
@@ -202,7 +201,7 @@ namespace Test.Utils.EfCrubDataAccess
202 201
                     }
203 202
                 };
204 203
                 var service = new LuUtilsPkGuidDataAccess(context);
205
-                var res = service.AddGuid(dbos);
204
+                var res = service.AddId(dbos);
206 205
                 Assert.Equal(LuStatus.Success, res.Status);
207 206
 
208 207
                 var edit = service.EditDbo(guid => guid.some_int == 42, guid => guid.some_int = -1);
@@ -400,7 +399,7 @@ namespace Test.Utils.EfCrubDataAccess
400 399
                     }
401 400
                 };
402 401
                 var service = new LuUtilsPkGuidDataAccess(context);
403
-                var res = service.AddGuid(dbos);
402
+                var res = service.AddId(dbos);
404 403
                 Assert.Equal(LuStatus.Success, res.Status);
405 404
                 var ids = res.Data.ToList();
406 405
 
@@ -452,11 +451,11 @@ namespace Test.Utils.EfCrubDataAccess
452 451
                     }
453 452
                 };
454 453
                 var service = new LuUtilsPkGuidDataAccess(context);
455
-                var res = service.AddGuid(dbos);
454
+                var res = service.AddId(dbos);
456 455
                 Assert.Equal(LuStatus.Success, res.Status);
457 456
                 var ids = res.Data.ToList();
458 457
 
459
-                var edit = service.EditSingleByIdGuid(ids[0], guid => guid.some_int = -1);
458
+                var edit = service.EditSingleByIdId(ids[0], guid => guid.some_int = -1);
460 459
                 Assert.Equal(LuStatus.Success, edit.Status);
461 460
 
462 461
                 var get = service.GetMultiple(guid => guid.some_text);
@@ -502,7 +501,7 @@ namespace Test.Utils.EfCrubDataAccess
502 501
                     }
503 502
                 };
504 503
                 var service = new LuUtilsPkGuidDataAccess(context);
505
-                var res = service.AddGuid(dbos);
504
+                var res = service.AddId(dbos);
506 505
                 Assert.Equal(LuStatus.Success, res.Status);
507 506
                 var ids = res.Data.ToList();
508 507
 
@@ -714,7 +713,7 @@ namespace Test.Utils.EfCrubDataAccess
714 713
                     }
715 714
                 };
716 715
                 var service = new LuUtilsPkGuidDataAccess(context);
717
-                var res = service.AddGuid(dbos);
716
+                var res = service.AddId(dbos);
718 717
                 Assert.Equal(LuStatus.Success, res.Status);
719 718
                 var ids = res.Data.ToList();
720 719
 
@@ -768,13 +767,13 @@ namespace Test.Utils.EfCrubDataAccess
768 767
                     }
769 768
                 };
770 769
                 var service = new LuUtilsPkGuidDataAccess(context);
771
-                var res = service.AddGuid(dbos);
770
+                var res = service.AddId(dbos);
772 771
                 Assert.Equal(LuStatus.Success, res.Status);
773 772
                 var ids = res.Data.ToList();
774 773
 
775 774
                 dbos[0].SomeInt = -1;
776 775
 
777
-                var edit = service.EditSingleByIdGuid(ids[0], dbos[0]);
776
+                var edit = service.EditSingleByIdId(ids[0], dbos[0]);
778 777
                 Assert.Equal(LuStatus.Success, edit.Status);
779 778
 
780 779
                 var get = service.GetMultiple(guid => guid.some_text);
@@ -820,7 +819,7 @@ namespace Test.Utils.EfCrubDataAccess
820 819
                     }
821 820
                 };
822 821
                 var service = new LuUtilsPkGuidDataAccess(context);
823
-                var res = service.AddGuid(dbos);
822
+                var res = service.AddId(dbos);
824 823
                 Assert.Equal(LuStatus.Success, res.Status);
825 824
                 var ids = res.Data.ToList();
826 825
 

+ 7
- 2
WebTest/Business/PkGuidBusiness.cs View File

@@ -6,10 +6,13 @@ using Test.Utils.Dbo.PkGuid;
6 6
 
7 7
 namespace WebTest.Business
8 8
 {
9
-    public class PkGuidBusiness : LuCrudBusiness<LuUtilsPkGuidDataAccess, PkGuidAddDbo, PkGuidDbo, PkGuidAddDbo>
9
+    public class PkGuidBusiness : LuCrudBusiness<LuUtilsPkGuidDataAccess, PkGuidAddDbo, PkGuidDbo, PkGuidAddDbo, string>
10 10
     {
11
-        public PkGuidBusiness(LuUtilsPkGuidDataAccess dataAccess) : base(dataAccess)
11
+        private readonly LuNotificationsBusiness _notificationsBusiness;
12
+
13
+        public PkGuidBusiness(LuUtilsPkGuidDataAccess dataAccess, LuNotificationsBusiness notificationsBusiness) : base(dataAccess)
12 14
         {
15
+            _notificationsBusiness = notificationsBusiness;
13 16
         }
14 17
 
15 18
         protected override LuResult<PkGuidAddDbo> CheckAdd(PkGuidAddDbo obj)
@@ -29,5 +32,7 @@ namespace WebTest.Business
29 32
             }
30 33
             return LuResult<PkGuidAddDbo>.Ok(update);
31 34
         }
35
+
36
+
32 37
     }
33 38
 }

+ 1
- 1
WebTest/Controllers/PkGuidController.cs View File

@@ -4,7 +4,7 @@ using WebTest.Business;
4 4
 
5 5
 namespace WebTest.Controllers
6 6
 {
7
-    public class PkGuidController : LuCrudController<PkGuidBusiness, PkGuidAddDbo, PkGuidDbo, PkGuidAddDbo>
7
+    public class PkGuidController : LuCrudController<PkGuidBusiness, PkGuidAddDbo, PkGuidDbo, PkGuidAddDbo, string>
8 8
     {
9 9
         public PkGuidController(PkGuidBusiness busines) : base(busines)
10 10
         {

Loading…
Cancel
Save