Пример #1
0
        /// <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 = true;//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);
        }