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.

LuNotificationsBusiness.cs 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using Luticate2.Utils.Hubs;
  2. using Microsoft.AspNetCore.SignalR;
  3. using Microsoft.AspNetCore.SignalR.Infrastructure;
  4. namespace Luticate2.Utils.Business
  5. {
  6. public class LuNotificationsBusiness
  7. {
  8. private readonly IHubContext _hubContext;
  9. public const string EventCreate = "EVENT_CREATE";
  10. public const string EventUpdate = "EVENT_UPDATE";
  11. public const string EventDelete = "EVENT_DELETE";
  12. public LuNotificationsBusiness(IConnectionManager connectionManager)
  13. {
  14. _hubContext = connectionManager.GetHubContext<LuNotificationsHub>();
  15. }
  16. public void Notify(string eventName, string entityType, object oldEntity, object newEntity)
  17. {
  18. _hubContext.Clients.All.notify(eventName, entityType, oldEntity, newEntity);
  19. }
  20. public void NotifyCreate(string entityType, object newEntity)
  21. {
  22. Notify(EventCreate, entityType, null, newEntity);
  23. }
  24. public void NotifyUpdate(string entityType, object oldEntity, object newEntity)
  25. {
  26. Notify(EventUpdate, entityType, oldEntity, newEntity);
  27. }
  28. public void NotifyDelete(string entityType, object oldEntity)
  29. {
  30. Notify(EventDelete, entityType, oldEntity, null);
  31. }
  32. }
  33. }