Beispiel #1
0
        public override async void Initialize(MainWindow mainWindow)
        {
            _adminClient = new AdminClientServiceClient();
            MainWindow   = mainWindow;

            #region View And ViewModel
            _view = new MatchesWindow();
            // Check if service is available
            if (!await AdminClientHelper.IsAvailable(_adminClient))
            {
                return;
            }
            var seasons = await _adminClient.GetSeasonsAsync();

            var matches = await _adminClient.GetMatchesAsync(seasons.FirstOrDefault());

            _viewModel = new MatchesWindowViewModel
            {
                Seasons                = seasons.ToList(),
                SelectedSeason         = seasons.FirstOrDefault(),
                Matches                = matches.ToList(),
                BackCommand            = new RelayCommand(ExecuteBackCommand),
                AddCommand             = new RelayCommand(ExecuteAddCommand),
                DeleteCommand          = new RelayCommand(ExecuteDeleteCommand),
                ChangeCommand          = new RelayCommand(ExecuteChangeCommand),
                GenerateMatchesCommand = new RelayCommand(ExecuteGenerateCommand),
                LoadMatchDayCommand    = new RelayCommand(ExecuteLoadMatchCommand)
            };
            _view.DataContext = _viewModel;
            _viewModel.SelectionSeasonChanged += UpdateSeason;
            #endregion

            _view.MatchesDataGrid.Loaded += SetMinWidths;
            MainWindow.Content            = _view;
        }
Beispiel #2
0
        public async void Initialize(MainWindow mainWindow, MenuWindowController menuWindow, Season selectedSeason, Bettor bettor)
        {
            _view           = new MatchesWindow();
            _bettorClient   = new BettorClientServiceClient();
            _mainWindow     = mainWindow;
            _menuWindow     = menuWindow;
            _selectedSeason = selectedSeason;
            _bettor         = bettor;

            #region View and ViewModel
            // Check if service is available
            if (!await BettorClientHelper.IsAvailable(_bettorClient))
            {
                return;
            }
            _viewModel = new MatchesWindowViewModel
            {
                SelectedSeason       = _selectedSeason,
                Matches              = LoadModels(),
                SelectedMatch        = SortedMatches().FirstOrDefault(),
                SelectedMatchCommand = new RelayCommand(ExecuteSelectedMatchCommand),
                BackCommand          = new RelayCommand(ExecuteBackCommand)
            };
            _view.DataContext = _viewModel;
            #endregion

            _mainWindow.Content = _view;
        }