|
@@ -6,17 +6,17 @@ using Luticate2.Utils.Interfaces;
|
6
|
6
|
|
7
|
7
|
namespace Luticate2.Utils.Business
|
8
|
8
|
{
|
9
|
|
- public abstract class LuCrudBusiness<TNextCrud, TDboCreate, TDboRead, TDboUpdate> : LuBusiness, ILuCrudInterface<TDboCreate, TDboRead, TDboUpdate>
|
10
|
|
- where TNextCrud : ILuCrudInterface<TDboCreate, TDboRead, TDboUpdate>
|
|
9
|
+ public abstract class LuCrudBusiness<TDataAccess, TDboCreate, TDboRead, TDboUpdate> : LuBusiness, ILuCrudInterface<TDboCreate, TDboRead, TDboUpdate>
|
|
10
|
+ where TDataAccess : ILuCrudInterface<TDboCreate, TDboRead, TDboUpdate>
|
11
|
11
|
where TDboCreate : class
|
12
|
12
|
where TDboRead : class
|
13
|
13
|
where TDboUpdate : class
|
14
|
14
|
{
|
15
|
|
- protected readonly TNextCrud NextCrud;
|
|
15
|
+ protected readonly TDataAccess DataAccess;
|
16
|
16
|
|
17
|
|
- protected LuCrudBusiness(TNextCrud nextCrud)
|
|
17
|
+ protected LuCrudBusiness(TDataAccess dataAccess)
|
18
|
18
|
{
|
19
|
|
- NextCrud = nextCrud;
|
|
19
|
+ DataAccess = dataAccess;
|
20
|
20
|
}
|
21
|
21
|
|
22
|
22
|
protected virtual LuResult<TDboCreate> CheckAdd(TDboCreate obj)
|
|
@@ -73,7 +73,7 @@ namespace Luticate2.Utils.Business
|
73
|
73
|
{
|
74
|
74
|
return res.To<T>();
|
75
|
75
|
}
|
76
|
|
- return NextCrud.Add(res.Data, returnFunc);
|
|
76
|
+ return DataAccess.Add(res.Data, returnFunc);
|
77
|
77
|
}
|
78
|
78
|
|
79
|
79
|
public LuResult<T> Add<T>(TDboCreate obj, Func<TDboRead, T> returnFunc)
|
|
@@ -83,7 +83,7 @@ namespace Luticate2.Utils.Business
|
83
|
83
|
{
|
84
|
84
|
return res.To<T>();
|
85
|
85
|
}
|
86
|
|
- return NextCrud.Add(res.Data, returnFunc);
|
|
86
|
+ return DataAccess.Add(res.Data, returnFunc);
|
87
|
87
|
}
|
88
|
88
|
|
89
|
89
|
public LuResult<IEnumerable<string>> AddGuid(IEnumerable<TDboCreate> objs)
|
|
@@ -93,7 +93,7 @@ namespace Luticate2.Utils.Business
|
93
|
93
|
{
|
94
|
94
|
return res.To<IEnumerable<string>>();
|
95
|
95
|
}
|
96
|
|
- return NextCrud.AddGuid(res.Data);
|
|
96
|
+ return DataAccess.AddGuid(res.Data);
|
97
|
97
|
}
|
98
|
98
|
|
99
|
99
|
public LuResult<string> AddGuid(TDboCreate obj)
|
|
@@ -103,7 +103,7 @@ namespace Luticate2.Utils.Business
|
103
|
103
|
{
|
104
|
104
|
return res.To<string>();
|
105
|
105
|
}
|
106
|
|
- return NextCrud.AddGuid(res.Data);
|
|
106
|
+ return DataAccess.AddGuid(res.Data);
|
107
|
107
|
}
|
108
|
108
|
|
109
|
109
|
public LuResult<IEnumerable<long>> AddId(IEnumerable<TDboCreate> obj)
|
|
@@ -113,7 +113,7 @@ namespace Luticate2.Utils.Business
|
113
|
113
|
{
|
114
|
114
|
return res.To<IEnumerable<long>>();
|
115
|
115
|
}
|
116
|
|
- return NextCrud.AddId(res.Data);
|
|
116
|
+ return DataAccess.AddId(res.Data);
|
117
|
117
|
}
|
118
|
118
|
|
119
|
119
|
public LuResult<long> AddId(TDboCreate obj)
|
|
@@ -123,7 +123,7 @@ namespace Luticate2.Utils.Business
|
123
|
123
|
{
|
124
|
124
|
return res.To<long>();
|
125
|
125
|
}
|
126
|
|
- return NextCrud.AddId(res.Data);
|
|
126
|
+ return DataAccess.AddId(res.Data);
|
127
|
127
|
}
|
128
|
128
|
|
129
|
129
|
public LuResult<IEnumerable<TDboRead>> AddDbo(IEnumerable<TDboCreate> obj)
|
|
@@ -133,7 +133,7 @@ namespace Luticate2.Utils.Business
|
133
|
133
|
{
|
134
|
134
|
return res.To<IEnumerable<TDboRead>>();
|
135
|
135
|
}
|
136
|
|
- return NextCrud.AddDbo(res.Data);
|
|
136
|
+ return DataAccess.AddDbo(res.Data);
|
137
|
137
|
}
|
138
|
138
|
|
139
|
139
|
public LuResult<TDboRead> AddDbo(TDboCreate obj)
|
|
@@ -143,7 +143,7 @@ namespace Luticate2.Utils.Business
|
143
|
143
|
{
|
144
|
144
|
return res.To<TDboRead>();
|
145
|
145
|
}
|
146
|
|
- return NextCrud.AddDbo(res.Data);
|
|
146
|
+ return DataAccess.AddDbo(res.Data);
|
147
|
147
|
}
|
148
|
148
|
|
149
|
149
|
|
|
@@ -151,17 +151,17 @@ namespace Luticate2.Utils.Business
|
151
|
151
|
|
152
|
152
|
public LuResult<TDboRead> GetSingleById(string id)
|
153
|
153
|
{
|
154
|
|
- return NextCrud.GetSingleById(id);
|
|
154
|
+ return DataAccess.GetSingleById(id);
|
155
|
155
|
}
|
156
|
156
|
|
157
|
157
|
public LuResult<TDboRead> GetSingleById(long id)
|
158
|
158
|
{
|
159
|
|
- return NextCrud.GetSingleById(id);
|
|
159
|
+ return DataAccess.GetSingleById(id);
|
160
|
160
|
}
|
161
|
161
|
|
162
|
162
|
public LuResult<LuPaginatedDbo<TDboRead>> GetMultiple(LuOrderByDbo orderBy, int page = 0, int perPage = int.MaxValue)
|
163
|
163
|
{
|
164
|
|
- return NextCrud.GetMultiple(orderBy, 0, perPage);
|
|
164
|
+ return DataAccess.GetMultiple(orderBy, 0, perPage);
|
165
|
165
|
}
|
166
|
166
|
|
167
|
167
|
|
|
@@ -174,7 +174,7 @@ namespace Luticate2.Utils.Business
|
174
|
174
|
{
|
175
|
175
|
return obj.To<T>();
|
176
|
176
|
}
|
177
|
|
- return NextCrud.EditSingleById(id, obj.Data, returnFunc);
|
|
177
|
+ return DataAccess.EditSingleById(id, obj.Data, returnFunc);
|
178
|
178
|
}
|
179
|
179
|
|
180
|
180
|
public LuResult<long> EditSingleByIdId(long id, TDboUpdate update)
|
|
@@ -184,7 +184,7 @@ namespace Luticate2.Utils.Business
|
184
|
184
|
{
|
185
|
185
|
return obj.To<long>();
|
186
|
186
|
}
|
187
|
|
- return NextCrud.EditSingleByIdId(id, obj.Data);
|
|
187
|
+ return DataAccess.EditSingleByIdId(id, obj.Data);
|
188
|
188
|
}
|
189
|
189
|
|
190
|
190
|
public LuResult<TDboRead> EditSingleByIdDbo(long id, TDboUpdate update)
|
|
@@ -194,7 +194,7 @@ namespace Luticate2.Utils.Business
|
194
|
194
|
{
|
195
|
195
|
return obj.To<TDboRead>();
|
196
|
196
|
}
|
197
|
|
- return NextCrud.EditSingleByIdDbo(id, obj.Data);
|
|
197
|
+ return DataAccess.EditSingleByIdDbo(id, obj.Data);
|
198
|
198
|
}
|
199
|
199
|
|
200
|
200
|
public LuResult<T> EditSingleById<T>(string id, TDboUpdate update, Func<TDboRead, T> returnFunc)
|
|
@@ -204,7 +204,7 @@ namespace Luticate2.Utils.Business
|
204
|
204
|
{
|
205
|
205
|
return obj.To<T>();
|
206
|
206
|
}
|
207
|
|
- return NextCrud.EditSingleById(id, obj.Data, returnFunc);
|
|
207
|
+ return DataAccess.EditSingleById(id, obj.Data, returnFunc);
|
208
|
208
|
}
|
209
|
209
|
|
210
|
210
|
public LuResult<string> EditSingleByIdGuid(string id, TDboUpdate update)
|
|
@@ -214,7 +214,7 @@ namespace Luticate2.Utils.Business
|
214
|
214
|
{
|
215
|
215
|
return obj.To<string>();
|
216
|
216
|
}
|
217
|
|
- return NextCrud.EditSingleByIdGuid(id, obj.Data);
|
|
217
|
+ return DataAccess.EditSingleByIdGuid(id, obj.Data);
|
218
|
218
|
}
|
219
|
219
|
|
220
|
220
|
public LuResult<TDboRead> EditSingleByIdDbo(string id, TDboUpdate update)
|
|
@@ -224,7 +224,7 @@ namespace Luticate2.Utils.Business
|
224
|
224
|
{
|
225
|
225
|
return obj.To<TDboRead>();
|
226
|
226
|
}
|
227
|
|
- return NextCrud.EditSingleByIdDbo(id, obj.Data);
|
|
227
|
+ return DataAccess.EditSingleByIdDbo(id, obj.Data);
|
228
|
228
|
}
|
229
|
229
|
|
230
|
230
|
|
|
@@ -232,32 +232,32 @@ namespace Luticate2.Utils.Business
|
232
|
232
|
|
233
|
233
|
public LuResult<T> DeleteSingleById<T>(string id, Func<TDboRead, T> returnFunc)
|
234
|
234
|
{
|
235
|
|
- return NextCrud.DeleteSingleById(id, returnFunc);
|
|
235
|
+ return DataAccess.DeleteSingleById(id, returnFunc);
|
236
|
236
|
}
|
237
|
237
|
|
238
|
238
|
public LuResult<string> DeleteSingleByIdGuid(string id)
|
239
|
239
|
{
|
240
|
|
- return NextCrud.DeleteSingleByIdGuid(id);
|
|
240
|
+ return DataAccess.DeleteSingleByIdGuid(id);
|
241
|
241
|
}
|
242
|
242
|
|
243
|
243
|
public LuResult<TDboRead> DeleteSingleByIdDbo(string id)
|
244
|
244
|
{
|
245
|
|
- return NextCrud.DeleteSingleByIdDbo(id);
|
|
245
|
+ return DataAccess.DeleteSingleByIdDbo(id);
|
246
|
246
|
}
|
247
|
247
|
|
248
|
248
|
public LuResult<T> DeleteSingleById<T>(long id, Func<TDboRead, T> returnFunc)
|
249
|
249
|
{
|
250
|
|
- return NextCrud.DeleteSingleById(id, returnFunc);
|
|
250
|
+ return DataAccess.DeleteSingleById(id, returnFunc);
|
251
|
251
|
}
|
252
|
252
|
|
253
|
253
|
public LuResult<long> DeleteSingleByIdId(long id)
|
254
|
254
|
{
|
255
|
|
- return NextCrud.DeleteSingleByIdId(id);
|
|
255
|
+ return DataAccess.DeleteSingleByIdId(id);
|
256
|
256
|
}
|
257
|
257
|
|
258
|
258
|
public LuResult<TDboRead> DeleteSingleByIdDbo(long id)
|
259
|
259
|
{
|
260
|
|
- return NextCrud.DeleteSingleByIdDbo(id);
|
|
260
|
+ return DataAccess.DeleteSingleByIdDbo(id);
|
261
|
261
|
}
|
262
|
262
|
}
|
263
|
263
|
}
|