public PatrolScheduleViewModel(IPatrolScheduleDataViewModel patrolDataViewModel,
                                       IPatrolRepository patrolRepository,
                                       Func <IPatrolScheduleDetailViewModel> patrolScheduleDetailViewModelFunc, //detail view model is the combo box selections and whatnot
                                       IEventAggregator eventAggregator)
        {
            _eventAggregator = eventAggregator;
            _patrolScheduleDetailViewModelFunc = patrolScheduleDetailViewModelFunc;

            //get events

            PatrolDataViewModel = patrolDataViewModel;
            eventAggregator.GetEvent <ScheduleDetailEvent>().Subscribe(ScheduleDetailActivated);

            CreateScheduleCommand = new DelegateCommand(OnCreateSchedule);
        }
        public PatrolScheduleView(IPatrolScheduleDataViewModel _patrolScheduleDataViewModel,
                                  IPatrolRepository _patrolRepository,
                                  Func <IPatrolScheduleDetailViewModel> _patrolScheduleDetailViewModel,
                                  IEventAggregator _eventAggregator)
        {
            InitializeComponent();

            PatrolRepository              = _patrolRepository;
            PatrolScheduleDataViewModel   = _patrolScheduleDataViewModel;
            PatrolScheduleDetailViewModel = _patrolScheduleDetailViewModel;
            EventAggregator = _eventAggregator;

            _patrolScheduleViewModel = new PatrolScheduleViewModel(_patrolScheduleDataViewModel,
                                                                   _patrolRepository,
                                                                   _patrolScheduleDetailViewModel,
                                                                   _eventAggregator);

            DataContext = _patrolScheduleViewModel;

            Loaded += PatrolScheduleView_Loaded;
        }
Пример #3
0
        // Views are loaded here via RelayCommand along with their view models and data services
        public MainViewModel(ICustomerListViewModel _customerListViewModel,
                             ICustomerRepository _customerDataService,
                             Func <ICustomerDetailViewModel> _customerDetailViewModel,
                             IEmployeeRepository _employeeDataService,
                             IEmployeeListViewModel _employeeListViewModel,
                             Func <IEmployeeDetailViewModel> _employeeDetailViewModel,
                             IEventAggregator _eventAggregator,
                             IPatrolScheduleDataViewModel _patrolScheduleDataViewModel,
                             IPatrolRepository _patrolRepository,
                             Func <IPatrolScheduleDetailViewModel> _patrolScheduleDetailViewModel,
                             IEmpScheduleReport empScheduleReport,
                             ICustomersLookupReport customerLookupReport,
                             ISearchViewModel _searchViewModel)
        {
            _custView             = new CustomerView(_customerListViewModel, _customerDataService, _customerDetailViewModel, _eventAggregator);
            _employeeView         = new EmployeeView(_employeeListViewModel, _employeeDataService, _employeeDetailViewModel, _eventAggregator);
            _scheduleView         = new PatrolScheduleView(_patrolScheduleDataViewModel, _patrolRepository, _patrolScheduleDetailViewModel, _eventAggregator);
            _searchView           = new SearchView(_searchViewModel);
            _empScheduleReport    = empScheduleReport;
            _customerLookupReport = customerLookupReport;

            SelectCustomerView = new RelayCommand(() => SelectedView = _custView);
            SelectEmployeeView = new RelayCommand(() => SelectedView = _employeeView);
            SelectScheduleView = new RelayCommand(() => SelectedView = _scheduleView);
            SelectSearchView   = new RelayCommand(() => SelectedView = _searchView);

            GenerateEmployeeSchedules = new RelayCommand(async() => await RunEmpScheduleReport());
            GenerateCustomerReport    = new RelayCommand(async() => await RunCustomerReport());


            EmpSchedules = new ObservableCollection <EmpScheduleModel>();
            Customers    = new ObservableCollection <CustomerReportModel>();


            ExitCommand = new RelayCommand(() => Shutdown());
        }