|
@@ -23,6 +23,12 @@ namespace Luticate2.Utils.Business
|
23
|
23
|
|
24
|
24
|
protected virtual string EntityType { get; set; }
|
25
|
25
|
|
|
26
|
+ protected virtual Func<string, TDboRead, bool> NotifyCreateFilter { get; set; }
|
|
27
|
+
|
|
28
|
+ protected virtual Func<string, TDboRead, TDboRead, bool> NotifyUpdateFilter { get; set; }
|
|
29
|
+
|
|
30
|
+ protected virtual Func<string, TDboRead, bool> NotifyDeleteFilter { get; set; }
|
|
31
|
+
|
26
|
32
|
protected LuCrudBusiness(TDataAccess dataAccess, LuNotificationsBusiness notificationsBusiness)
|
27
|
33
|
{
|
28
|
34
|
DataAccess = dataAccess;
|
|
@@ -87,7 +93,8 @@ namespace Luticate2.Utils.Business
|
87
|
93
|
var newEntity = DataAccess.AddDbo(res.Data);
|
88
|
94
|
if (newEntity)
|
89
|
95
|
{
|
90
|
|
- _notificationsBusiness.NotifyCreate(EntityType, newEntity.Data);
|
|
96
|
+ _notificationsBusiness.NotifyCreate(EntityType, newEntity.Data,
|
|
97
|
+ s => NotifyCreateFilter(s, newEntity.Data));
|
91
|
98
|
return LuResult<T>.Ok(returnFunc(newEntity.Data));
|
92
|
99
|
}
|
93
|
100
|
return newEntity.To<T>();
|
|
@@ -153,7 +160,8 @@ namespace Luticate2.Utils.Business
|
153
|
160
|
var editedEntity = DataAccess.EditSingleByIdDbo(id, obj.Data);
|
154
|
161
|
if (editedEntity)
|
155
|
162
|
{
|
156
|
|
- _notificationsBusiness.NotifyUpdate(EntityType, originalEntity.Data, editedEntity.Data);
|
|
163
|
+ _notificationsBusiness.NotifyUpdate(EntityType, originalEntity.Data, editedEntity.Data,
|
|
164
|
+ s => NotifyUpdateFilter(s, originalEntity.Data, editedEntity.Data));
|
157
|
165
|
return LuResult<T>.Ok(returnFunc(editedEntity.Data));
|
158
|
166
|
}
|
159
|
167
|
return editedEntity.To<T>();
|
|
@@ -182,7 +190,8 @@ namespace Luticate2.Utils.Business
|
182
|
190
|
var res = DataAccess.DeleteSingleById(id, returnFunc);
|
183
|
191
|
if (res)
|
184
|
192
|
{
|
185
|
|
- _notificationsBusiness.NotifyDelete(EntityType, originalEntity.Data);
|
|
193
|
+ _notificationsBusiness.NotifyDelete(EntityType, originalEntity.Data,
|
|
194
|
+ s => NotifyDeleteFilter(s, originalEntity.Data));
|
186
|
195
|
}
|
187
|
196
|
return res;
|
188
|
197
|
}
|