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.NotifyCreate(GetEntityType(crudType), newEntity); } public void NotifyUpdate(Type crudType, object oldEntity, object newEntity) { _luWebSocketNotificationsBusiness.NotifyUpdate(GetEntityType(crudType), oldEntity, newEntity); } public void NotifyDelete(Type crudType, object oldEntity) { _luWebSocketNotificationsBusiness.NotifyDelete(GetEntityType(crudType), oldEntity); } } }