Exemplo n.º 1
0
        public AllDepartmentsViewModel(IStaffManagerNavigationService navigationService, IStaffManagerDataService dataService)
        {
            _navigationService = navigationService;
            _dataService       = dataService;

            Caption = "All Departments";
            SetLazyLoadingMode();

            ViewDepartmentCommand = new perRelayCommand(OnViewDepartment, () => SelectedDepartment != null)
                                    .ObservesInternalProperty(this, nameof(SelectedDepartment));

            AddNewDepartmentCommand = new perRelayCommand(OnAddNewDepartment);
        }
        public DepartmentViewModel(IStaffManagerNavigationService navigationService, IStaffManagerDataService dataService)
        {
            _dataService       = dataService;
            _navigationService = navigationService;

            // creates a expansion toggle button in lazy loading mode
            SetLazyLoadingMode();

            ViewPersonCommand = new perRelayCommand(OnViewPerson, () => SelectedPerson != null)
                                .ObservesInternalProperty(this, nameof(SelectedPerson));

            AddNewPersonCommand = new perRelayCommand(OnAddNewPerson);
        }
        public MainViewModel(IStaffManagerDataService dataService, IStaffManagerNavigationService navigationService)
        {
            _dataService       = dataService;
            _navigationService = navigationService;

            LoadDataCommand = new perRelayCommandAsync(RefreshDataAsync);
            perMessageService.RegisterMessageHandler <SelectItemMessage>(this, msg => SelectedItem = msg.SelectedItem);

            SelectPreviousSearchCommand = new RelayCommand(OnSelectPreviousSearch, () => _peopleMatchingSearchCollection.Count > 1)
                                          .ObservesCollection(_peopleMatchingSearchCollection);

            SelectNextSearchCommand = new RelayCommand(OnSelectNextSearch, () => _peopleMatchingSearchCollection.Count > 1)
                                      .ObservesCollection(_peopleMatchingSearchCollection);

            EditSelectedItemCommand = new RelayCommand(OnEditSelectedItem, () => SelectedItem is smViewModelBase)
                                      .ObservesInternalProperty(this, nameof(SelectedItem));
        }