/// <summary> /// Initializes a new instance of the <see cref="SendNewMailViewModel"/> class. /// </summary> /// <param name="userDialogService">The user dialog service.</param> /// <param name="asyncRequestDispatcherFactory">The async request dispatcher factory.</param> /// <param name="accessControlManager">The access control manager.</param> /// <param name="commandFactory">The command factory.</param> /// <param name="eventAggregator">The event aggregator.</param> /// <param name="popupService">The popup service.</param> /// <param name="currentUserContextService">The current user context service.</param> public SendNewMailViewModel( IUserDialogService userDialogService, IAsyncRequestDispatcherFactory asyncRequestDispatcherFactory, IAccessControlManager accessControlManager, ICommandFactory commandFactory, IEventAggregator eventAggregator, IPopupService popupService, ICurrentUserContextService currentUserContextService ) : base(accessControlManager, commandFactory) { _userDialogService = userDialogService; _asyncRequestDispatcherFactory = asyncRequestDispatcherFactory; _eventAggregator = eventAggregator; _popupService = popupService; currentUserContextService.RegisterForContext ( ( cuc, b ) => _currentContext = cuc ); SelectedFiles = new ObservableCollection<FileInfo> (); // UI Commands SendNewMailCommand = CommandFactoryHelper .CreateHelper ( this, commandFactory ) .BuildDelegateCommand(() => SendNewMailCommand, ExecuteSendNewMail); OpenAddressBookCommand = CommandFactoryHelper .CreateHelper ( this, commandFactory ) .BuildDelegateCommand ( () => OpenAddressBookCommand, ExecuteOpenAddressBook ); AddFilesCommand = CommandFactoryHelper .CreateHelper(this, commandFactory).BuildDelegateCommand<IEnumerable<FileInfo>>(() => AddFilesCommand, ExecuteAddFiles); // Navigation Commands OpenSendNewMailViewCommand = NavigationCommandManager.BuildCommand ( () => OpenSendNewMailViewCommand, NavigateToOpenSendNewMailViewCommand ); _eventAggregator.GetEvent<DirectAddressRecipientSelectedEvent> ().Subscribe ( HandleDirectAddressRecipientSelectedEventHandler ); }
/// <summary> /// Currents the user context changed. /// </summary> /// <param name="currentUserContext">The current user context.</param> /// <param name="firstCall">If set to <c>true</c> [first call].</param> public void CurrentUserContextChanged( CurrentUserContext currentUserContext, bool firstCall ) { _currentUserContext = currentUserContext; }
private void ChangeContext( CurrentUserContext currentUserContext, bool isInit = false ) { lock ( _currentUserContextSync ) { CurrentUserContext = currentUserContext; //change context to have new location _currentUserContextWeakDelegatesManager.Raise ( CurrentUserContext, isInit ); } }
private void InitializeUserInformation( UserInformationDto userInformationDto ) { lock ( _userPermissionsSync ) { lock ( _currentUserContextSync ) { _userPermissions.Clear (); foreach ( var grantedPermission in userInformationDto.GrantedPermissions ) { var permission = new Permission { Name = grantedPermission }; _userPermissions.Add ( permission ); } var agency = new AgencyContext ( userInformationDto.AgencyKey, userInformationDto.AgencyDisplayName ); var location = new LocationContext ( userInformationDto.LocationKey, userInformationDto.LocationDisplayName ); var staff = new StaffContext ( userInformationDto.StaffKey, userInformationDto.StaffFirstName, userInformationDto.StaffMiddleName, userInformationDto.StaffLastName, userInformationDto.DirectEmailAddress ); var account = new AccountContext ( userInformationDto.AccountKey, userInformationDto.AccountIdentifier ); var currentUserContext = new CurrentUserContext ( agency, location, staff, account ); CurrentUserContext = currentUserContext; } } }
/// <summary> /// Called when [context changed]. /// </summary> /// <param name="currentUserContext">The current user context.</param> /// <param name="firstCall">If set to <c>true</c> [first call].</param> public void OnContextChanged ( CurrentUserContext currentUserContext, bool firstCall ) { if ( firstCall || ApplyContextChanges ) { CurrentUserContext = currentUserContext; } ContextChanged ( this, new EventArgs () ); }