123456789101112131415161718192021222324252627282930313233343536373839404142 |
- using Luticate2.Utils.Hubs;
- using Microsoft.AspNetCore.SignalR;
- using Microsoft.AspNetCore.SignalR.Infrastructure;
-
- namespace Luticate2.Utils.Business
- {
- public class LuNotificationsBusiness
- {
- private readonly IHubContext _hubContext;
-
- public const string EventCreate = "EVENT_CREATE";
-
- public const string EventUpdate = "EVENT_UPDATE";
-
- public const string EventDelete = "EVENT_DELETE";
-
- public LuNotificationsBusiness(IConnectionManager connectionManager)
- {
- _hubContext = connectionManager.GetHubContext<LuNotificationsHub>();
- }
-
- public void Notify(string eventName, string entityType, object oldEntity, object newEntity)
- {
- _hubContext.Clients.All.notify(eventName, entityType, oldEntity, newEntity);
- }
-
- public void NotifyCreate(string entityType, object newEntity)
- {
- Notify(EventCreate, entityType, null, newEntity);
- }
-
- public void NotifyUpdate(string entityType, object oldEntity, object newEntity)
- {
- Notify(EventUpdate, entityType, oldEntity, newEntity);
- }
-
- public void NotifyDelete(string entityType, object oldEntity)
- {
- Notify(EventDelete, entityType, oldEntity, null);
- }
- }
- }
|