/// <summary> /// Initializes an instance of <see cref="ManageViewModel"/>. /// </summary> /// <param name="registeredName"></param> /// <param name="userRepository"></param> /// <param name="messagingService"></param> /// <param name="canUserNavigate"></param> public ManageViewModel(string registeredName, IUserRepository userRepository, IMessagingService messagingService,bool canUserNavigate) : base(registeredName,canUserNavigate) { if (userRepository == null) throw new ArgumentNullException("userRepository"); if (messagingService == null) throw new ArgumentNullException("messagingService"); _userRepository = userRepository; _messagingService = messagingService; DisplayName = UIText.MANAGE_VIEW_HEADER; CanGoBack = true; Users = new ExtendedObservableCollection<UserViewModel>(); //Intialize commands RefreshUserListCommand = new RelayCommand(RefreshUserList); SaveUsersCommand = new RelayCommand(SaveUser, CanSaveUser); AddNewUserCommand = new RelayCommand(() => SelectedUser = new UserViewModel(_userRepository.GetNewUser(),_messagingService)); }
/// <summary> /// Initializes an instance of <see cref="ApplicationViewModel"/>. /// </summary> /// <param name="user">The view model that wraps the logged in user model. </param> /// <param name="transactionRepository">An instance of <see cref="ITransactionRepository"/> implementation.</param> /// <param name="userRepository"> >An instance of <see cref="IUserRepository"/> implementation.</param> /// <param name="messagingService">An implementation of <see cref="IMessagingService"/> </param> public ApplicationViewModel(UserViewModel user,ITransactionRepository transactionRepository, IUserRepository userRepository, IMessagingService messagingService) : base("ApplicationViewModel") { LoggedInUser = user; bool isUserAdmin = user.Role == UserRole.Admin; //Configure the navigator Navigator = NavigatorFactory.GetNavigator(); var viewList = new List<WorkspaceViewModelBase>() { new AllTransactionViewModel(isUserAdmin,Constants.ALLEXPENSES_VIEW_REGERED_NAME,userRepository,transactionRepository,messagingService), new ManageViewModel(Constants.MANAGE_VIEW_REGERED_NAME,userRepository,messagingService,isUserAdmin) }; viewList.ForEach(wvm => Navigator.AddView(wvm)); Navigator.AddHomeView(new HomeViewModel(viewList, Constants.HOME_VIEW_REGERED_NAME, messagingService)); Navigator.PropertyChanged += NavigatorPropertyChanged; Navigator.NavigateToHome(); //Initialie the commands NavigateBackCommand = new RelayCommand(Navigator.NavigateBack); }