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(); } 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); } } }