Browse Source

moved GetCrudEntityType method in extension method

tags/v0.6.0
Robin Thoni 7 years ago
parent
commit
233dc1d081

+ 3
- 17
Luticate2.Utils/Business/LuCrudWebSocketNotificationsBusiness.cs View File

@@ -12,33 +12,19 @@ namespace Luticate2.Utils.Business
12 12
             _luWebSocketNotificationsBusiness = luWebSocketNotificationsBusiness;
13 13
         }
14 14
 
15
-        public string GetEntityType(Type crudType)
16
-        {
17
-            var name = crudType.Name;
18
-            if (name.EndsWith("Business"))
19
-            {
20
-                name = name.Remove(name.Length - 8);
21
-            }
22
-            if (name.Length > 0 && char.IsUpper(name[0]))
23
-            {
24
-                name = char.ToLower(name[0]) + name.Remove(0, 1);
25
-            }
26
-            return name;
27
-        }
28
-
29 15
         public void NotifyCreate(Type crudType, object newEntity)
30 16
         {
31
-            _luWebSocketNotificationsBusiness.NotifyCrudCreate(GetEntityType(crudType), newEntity);
17
+            _luWebSocketNotificationsBusiness.NotifyCrudCreate(crudType.GetCrudEntityType(), newEntity);
32 18
         }
33 19
 
34 20
         public void NotifyUpdate(Type crudType, object oldEntity, object newEntity)
35 21
         {
36
-            _luWebSocketNotificationsBusiness.NotifyCrudUpdate(GetEntityType(crudType), oldEntity, newEntity);
22
+            _luWebSocketNotificationsBusiness.NotifyCrudUpdate(crudType.GetCrudEntityType(), oldEntity, newEntity);
37 23
         }
38 24
 
39 25
         public void NotifyDelete(Type crudType, object oldEntity)
40 26
         {
41
-            _luWebSocketNotificationsBusiness.NotifyCrudDelete(GetEntityType(crudType), oldEntity);
27
+            _luWebSocketNotificationsBusiness.NotifyCrudDelete(crudType.GetCrudEntityType(), oldEntity);
42 28
         }
43 29
     }
44 30
 }

+ 16
- 1
Luticate2.Utils/Business/LuUtilsBusinessExtensions.cs View File

@@ -1,4 +1,5 @@
1
-using Luticate2.Utils.Dbo.Basic;
1
+using System;
2
+using Luticate2.Utils.Dbo.Basic;
2 3
 using Luticate2.Utils.Interfaces;
3 4
 
4 5
 namespace Luticate2.Utils.Business
@@ -19,5 +20,19 @@ namespace Luticate2.Utils.Business
19 20
         {
20 21
             business.Notify(LuUtilsConstants.EventDelete, entityType, oldEntity, null);
21 22
         }
23
+
24
+        public static string GetCrudEntityType(this Type crudType)
25
+        {
26
+            var name = crudType.Name;
27
+            if (name.EndsWith("Business"))
28
+            {
29
+                name = name.Remove(name.Length - 8);
30
+            }
31
+            if (name.Length > 0 && char.IsUpper(name[0]))
32
+            {
33
+                name = char.ToLower(name[0]) + name.Remove(0, 1);
34
+            }
35
+            return name;
36
+        }
22 37
     }
23 38
 }

Loading…
Cancel
Save