You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

LuUtilsBusinessExtensions.cs 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. using System;
  2. using Luticate2.Utils.Dbo.Basic;
  3. using Luticate2.Utils.Interfaces;
  4. namespace Luticate2.Utils.Business
  5. {
  6. public static class LuUtilsBusinessExtensions
  7. {
  8. public static void NotifyCrudCreate(this ILuNotificationsBusiness business, string entityType, object newEntity)
  9. {
  10. business.Notify(LuUtilsConstants.EventCreate, entityType, null, newEntity);
  11. }
  12. public static void NotifyCrudUpdate(this ILuNotificationsBusiness business, string entityType, object oldEntity, object newEntity)
  13. {
  14. business.Notify(LuUtilsConstants.EventUpdate, entityType, oldEntity, newEntity);
  15. }
  16. public static void NotifyCrudDelete(this ILuNotificationsBusiness business, string entityType, object oldEntity)
  17. {
  18. business.Notify(LuUtilsConstants.EventDelete, entityType, oldEntity, null);
  19. }
  20. public static string GetCrudEntityType(this Type crudType)
  21. {
  22. var name = crudType.Name;
  23. if (name.EndsWith("Business"))
  24. {
  25. name = name.Remove(name.Length - 8);
  26. }
  27. if (name.Length > 0 && char.IsUpper(name[0]))
  28. {
  29. name = char.ToLower(name[0]) + name.Remove(0, 1);
  30. }
  31. return name;
  32. }
  33. }
  34. }