1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- using System;
- using Luticate2.Utils.Interfaces;
-
- namespace Luticate2.Utils.Business
- {
- public class LuCrudWebSocketNotificationsBusiness : ILuCrudWebSocketNotificationsBusiness
- {
- private readonly ILuWebSocketNotificationsBusiness _luWebSocketNotificationsBusiness;
-
- public LuCrudWebSocketNotificationsBusiness(ILuWebSocketNotificationsBusiness luWebSocketNotificationsBusiness)
- {
- _luWebSocketNotificationsBusiness = luWebSocketNotificationsBusiness;
- }
-
- public string GetEntityType(Type crudType)
- {
- var name = crudType.Name;
- if (name.EndsWith("Business"))
- {
- name = name.Remove(name.Length - 8);
- }
- if (name.Length > 0 && char.IsUpper(name[0]))
- {
- name = char.ToLower(name[0]) + name.Remove(0, 1);
- }
- return name;
- }
-
- public void NotifyCreate(Type crudType, object newEntity)
- {
- _luWebSocketNotificationsBusiness.NotifyCrudCreate(GetEntityType(crudType), newEntity);
- }
-
- public void NotifyUpdate(Type crudType, object oldEntity, object newEntity)
- {
- _luWebSocketNotificationsBusiness.NotifyCrudUpdate(GetEntityType(crudType), oldEntity, newEntity);
- }
-
- public void NotifyDelete(Type crudType, object oldEntity)
- {
- _luWebSocketNotificationsBusiness.NotifyCrudDelete(GetEntityType(crudType), oldEntity);
- }
- }
- }
|