private void HandleSaveUserPreferencesMessage(SaveUserPreferencesMessage message)
        {
            this.userPreferencesById.TryGetValue(message.UserId, out var existingUserPreferences);

            if (existingUserPreferences?.EmailNotifications != message.UserPreferences.EmailNotifications)
            {
                var emailNotificationsEvent = new EmailNotificationsPreferenceChangedEvent(message.UserId, message.UserPreferences.EmailNotifications);
                this.Persist(emailNotificationsEvent, this.OnEmailNotificationsPreferenceChanged);
            }

            if (existingUserPreferences?.PushNotifications != message.UserPreferences.PushNotifications)
            {
                var pushNotificationsEvent = new PushNotificationsPreferenceChangedEvent(message.UserId, message.UserPreferences.PushNotifications);
                this.Persist(pushNotificationsEvent, this.OnPushNotificationsPreferenceChanged);
            }

            if (existingUserPreferences?.DependentDepartmentsPendingActions != message.UserPreferences.DependentDepartmentsPendingActions)
            {
                var dependentDepartmentsEvent = new DependentDepartmentsPendingActionsPreferenceChangedEvent(
                    message.UserId,
                    message.UserPreferences.DependentDepartmentsPendingActions);
                this.Persist(dependentDepartmentsEvent, this.OnDependentDepartmentsPendingActionsPreferenceChanged);
            }

            this.Sender.Tell(new SaveUserPreferencesMessage.Response());
        }
예제 #2
0
 private void OnEmailNotificationsPreferenceChanged(EmailNotificationsPreferenceChangedEvent @event)
 {
     this.SetDefaultPreferencesIfNotExists(@event.UserId);
     this.userPreferencesById[@event.UserId].EmailNotifications = @event.EmailNotifications;
 }