Exemple #1
0
        public IList <NotificationAccessException> GetNotificationAccessExceptionsForCurrentUser()
        {
            var loggedUser = AuthenticationProvider.GetLoggedUser();
            var userNotificationExceptions = NotificationAccessExceptions.Where(x => x.Users.Any(y => y == loggedUser)).ToList();

            return(userNotificationExceptions);
        }
Exemple #2
0
        private void CreateNotifications()
        {
            var notificationTypes = NotificationTypes();

            foreach (var notificationType in notificationTypes)
            {
                var notification       = (Notification)Activator.CreateInstance(notificationType);
                var notificationAccess = new NotificationAccess(notification);
                Notifications.Put(notification);
                NotificationAccesses.Put(notificationAccess);
                var notificationAccessException = new NotificationAccessException(notification);
                NotificationAccessExceptions.Put(notificationAccessException);
                notification.NotificationAccessException = notificationAccessException;
                notification.NotificationAccess          = notificationAccess;
            }
        }
Exemple #3
0
        public void UpdateExceptionsForUser(IEnumerable <int> exceptions)
        {
            var loggedUser       = AuthenticationProvider.GetLoggedUser();
            var oldExceptions    = NotificationAccessExceptions.Where(x => x.Users.Any(y => y == loggedUser));
            var oldExceptionsIds = oldExceptions.Select(x => x.Id);
            var newExceptionsIds = NotificationAccessExceptions.Where(x => exceptions.Contains(x.AssociatedNotification.Id)).Select(x => x.Id);

            var exceptionsToRemove = oldExceptions.Where(x => !newExceptionsIds.Contains(x.Id));

            foreach (var notificationAccessException in exceptionsToRemove)
            {
                notificationAccessException.Users.Remove(loggedUser);
            }

            var exceptionsToAdd = newExceptionsIds.Where(x => !oldExceptionsIds.Contains(x));

            foreach (var newException in exceptionsToAdd)
            {
                var notificationException = NotificationAccessExceptions[newException];
                notificationException.Users.Add(loggedUser);
            }
        }