Ejemplo n.º 1
0
        private void SendNotification(Notification notification)
        {
            var context = GlobalHost.ConnectionManager.GetHubContext <NotificationHub>();
            var userId  = NotificationHub.GetConnectionUserId(notification.UserId);

            var notificationViewModel = Mapper.Map <NotificationViewModel>(notification);

            notificationViewModel.UserId = userId;

            if (userId != null)
            {
                context.Clients.Client(userId).addNotification(notificationViewModel);
            }
        }
Ejemplo n.º 2
0
        protected void SendNotification(Notification notification)
        {
            this.Data.Notifications.Add(notification);
            this.Data.SaveChanges();

            var context = GlobalHost.ConnectionManager.GetHubContext <NotificationHub>();
            var userId  = NotificationHub.GetConnectionUserId(notification.UserId);

            var notificationViewModel = Mapper.Map <NotificationViewModel>(notification);

            notificationViewModel.UserId = userId;

            if (userId != null)
            {
                context.Clients.Client(userId).addNotification(notificationViewModel);
            }
        }