Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

LuCrudWebSocketNotificationsBusiness.cs 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using System;
  2. using Luticate2.Utils.Interfaces;
  3. namespace Luticate2.Utils.Business
  4. {
  5. public class LuCrudWebSocketNotificationsBusiness : ILuCrudWebSocketNotificationsBusiness
  6. {
  7. private readonly ILuWebSocketNotificationsBusiness _luWebSocketNotificationsBusiness;
  8. public LuCrudWebSocketNotificationsBusiness(ILuWebSocketNotificationsBusiness luWebSocketNotificationsBusiness)
  9. {
  10. _luWebSocketNotificationsBusiness = luWebSocketNotificationsBusiness;
  11. }
  12. public string GetEntityType(Type crudType)
  13. {
  14. var name = crudType.Name;
  15. if (name.EndsWith("Business"))
  16. {
  17. name = name.Remove(name.Length - 8);
  18. }
  19. if (name.Length > 0 && char.IsUpper(name[0]))
  20. {
  21. name = char.ToLower(name[0]) + name.Remove(0, 1);
  22. }
  23. return name;
  24. }
  25. public void NotifyCreate(Type crudType, object newEntity)
  26. {
  27. _luWebSocketNotificationsBusiness.NotifyCrudCreate(GetEntityType(crudType), newEntity);
  28. }
  29. public void NotifyUpdate(Type crudType, object oldEntity, object newEntity)
  30. {
  31. _luWebSocketNotificationsBusiness.NotifyCrudUpdate(GetEntityType(crudType), oldEntity, newEntity);
  32. }
  33. public void NotifyDelete(Type crudType, object oldEntity)
  34. {
  35. _luWebSocketNotificationsBusiness.NotifyCrudDelete(GetEntityType(crudType), oldEntity);
  36. }
  37. }
  38. }