public ActionResult Add(NotificationsTB NotificationsTB) { try { if (!ModelState.IsValid) { return(View(NotificationsTB)); } _INotification.DisableExistingNotifications(); var Notifications = new NotificationsTB { CreatedOn = DateTime.Now, Message = NotificationsTB.Message, NotificationsID = 0, Status = "A", FromDate = NotificationsTB.FromDate, ToDate = NotificationsTB.ToDate }; _INotification.AddNotification(Notifications); MyNotificationHub.Send(); return(RedirectToAction("Add", "AddNotification")); } catch (Exception) { throw; } }
private static void dependency_OnChange(object sender, SqlNotificationEventArgs e) { if (dependency != null) { dependency.OnChange -= dependency_OnChange; dependency = null; } if (e.Type == SqlNotificationType.Change) { MyNotificationHub.Send(); } }