示例#1
0
        protected override async void ExecuteDeleteCommand(object obj)
        {
            if (_viewModel.SelectedTeam == null)
            {
                MessageBox.Show("Bitte wählen Sie eine Mannschaft aus!", "Keine Mannschaft ausgewählt",
                                MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }
            // Check if the user really want to delete the bettor
            var messageBoxResult = MessageBox.Show("Sind Sie sicher, dass die Mannschaft gelöscht werden soll!", "Mannschaft löschen",
                                                   MessageBoxButton.YesNo, MessageBoxImage.Warning);

            if (messageBoxResult != MessageBoxResult.Yes)
            {
                return;
            }
            // Check if service is available
            if (!await AdminClientHelper.IsAvailable(_adminClient))
            {
                return;
            }
            // delete bettor
            var isDeleted = _adminClient.DeleteTeam(_viewModel.SelectedTeam);

            UpdateModels(isDeleted, "Mannschaft konnte nicht gelöscht werden!", "Löschen fehlgeschlagen");
        }
示例#2
0
        public override async void Initialize(MainWindow mainWindow)
        {
            MainWindow   = mainWindow;
            _view        = new TeamWindow();
            _adminClient = new AdminClientServiceClient();

            #region View and ViewModel
            // Check if service is available
            if (!await AdminClientHelper.IsAvailable(_adminClient))
            {
                return;
            }

            var teams = await _adminClient.GetAllTeamsAsync();

            _viewModel = new TeamWindowViewModel
            {
                Teams         = teams.ToList(),
                BackCommand   = new RelayCommand(ExecuteBackCommand),
                AddCommand    = new RelayCommand(ExecuteAddCommand),
                DeleteCommand = new RelayCommand(ExecuteDeleteCommand),
                ChangeCommand = new RelayCommand(ExecuteChangeCommand)
            };

            _view.DataContext = _viewModel;
            #endregion

            MainWindow.Content = _view;
        }
示例#3
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;
        }
示例#4
0
        protected override async void ExecuteAddCommand(object obj)
        {
            var teams = await _adminClient.GetSeasonToTeamRelationAsync(_viewModel.SelectedSeason);

            var addBettorWindow = new AddMatchWindowController
            {
                Match = new Match
                {
                    Season   = _viewModel.SelectedSeason,
                    DateTime = DateTime.Now,
                    MatchDay = 1
                },
                AwayTeams = teams.Select(x => x.Team).ToList(),
                HomeTeams = teams.Select(x => x.Team).ToList(),
            };

            var showMatch = addBettorWindow.ShowMatch();

            // it could be possible that the bettor is null
            if (showMatch == null)
            {
                return;
            }
            // Check if service is available
            if (!await AdminClientHelper.IsAvailable(_adminClient))
            {
                return;
            }
            // add bettor
            var isAdded = await _adminClient.AddMatchAsync(showMatch);

            UpdateModels(isAdded, "Spiel konnte nicht hinzugefügt werden, da es schon existiert!",
                         "Hinzufügen fehlgeschlagen");
        }
示例#5
0
        protected override async void ExecuteChangeCommand(object obj)
        {
            if (_viewModel.SelectedBettor == null)
            {
                MessageBox.Show("Bitte wählen Sie einen Tipper aus!", "Kein Tipper ausgewählt",
                                MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            var addBettorWindow = new AddBettorWindowController
            {
                Bettor = _viewModel.SelectedBettor
            };

            var showBettor = addBettorWindow.ShowBettor();

            // it could be possible that the bettor is null
            if (showBettor == null)
            {
                ReloadModels();
                return;
            }
            // Check if service is available
            if (!await AdminClientHelper.IsAvailable(_adminClient))
            {
                return;
            }
            // add bettor
            var isUpdated = await _adminClient.UpdateBettorAsync(showBettor);

            UpdateModels(isUpdated, "Der Benutzer konnte nicht geändert werden!", "Änderung fehlgeschlagen");
        }
示例#6
0
        protected override async void ExecuteAddCommand(object obj)
        {
            var addBettorWindow = new AddBettorWindowController
            {
                Bettor = new Bettor()
            };

            var showBettor = addBettorWindow.ShowBettor();

            // it could be possible that the bettor is null
            if (showBettor == null)
            {
                return;
            }
            // Check if service is available
            if (!await AdminClientHelper.IsAvailable(_adminClient))
            {
                return;
            }
            // add bettor
            var isAdded = await _adminClient.AddBettorAsync(showBettor);

            UpdateModels(isAdded, "Tipper konnte nicht hinzugefügt werden, da der Nickname schon vergeben ist!",
                         "Hinzufügen fehlgeschlagen");
        }
示例#7
0
        public override async void Initialize(MainWindow mainWindow)
        {
            MainWindow   = mainWindow;
            _adminClient = new AdminClientServiceClient();
            // Check if service is available
            if (!await AdminClientHelper.IsAvailable(_adminClient))
            {
                return;
            }
            // Get all bettors
            var bettors = _adminClient.GetBettors();

            #region View and ViewModel
            _view      = new BettorWindow();
            _viewModel = new BettorWindowViewModel
            {
                BackCommand   = new RelayCommand(ExecuteBackCommand),
                AddCommand    = new RelayCommand(ExecuteAddCommand),
                DeleteCommand = new RelayCommand(ExecuteDeleteCommand),
                ChangeCommand = new RelayCommand(ExecuteChangeCommand),
                Bettors       = bettors.ToList()
            };

            _view.DataContext = _viewModel;
            #endregion

            MainWindow.Content = _view;
        }
示例#8
0
        protected override async void ExecuteAddCommand(object obj)
        {
            // Add Season to choose
            var seasons = await _adminClient.GetSeasonsAsync();

            var result = new List <SeasonCheckBox>();

            // Create SeasonCheckBox
            seasons.ToList().ForEach(x =>
            {
                result.Add(new SeasonCheckBox
                {
                    Season = x,
                    // Default is null
                    IsAdded = false
                });
            });

            var addBettorWindow = new AddTeamWindowController
            {
                Team    = new Team(),
                Seasons = result
            };

            var showTeam = addBettorWindow.ShowTeam();

            // it could be possible that the bettor is null
            if (showTeam == null)
            {
                return;
            }
            // Check if service is available
            if (!await AdminClientHelper.IsAvailable(_adminClient))
            {
                return;
            }
            // add bettor
            var isAdded = await _adminClient.AddTeamAsync(showTeam);

            var addedSeasons  = addBettorWindow.Seasons.FindAll(x => x.IsAdded);
            var allTeamsAsync = await _adminClient.GetAllTeamsAsync();

            var team = allTeamsAsync.ToList().Find(x => x.Name.ToUpper().Equals(showTeam.Name.ToUpper()));

            if (addedSeasons.Any())
            {
                addedSeasons.ToList().ForEach(x => _adminClient.AddSeasonToTeamRelation(new SeasonToTeamRelation {
                    Team = team, Season = x.Season
                }));
            }
            UpdateModels(isAdded, "Mannschaft konnte nicht hinzugefügt werden, da der Name schon vergeben ist!", "Hinzufügen fehlgeschlagen");
        }
示例#9
0
        protected override async void ExecuteChangeCommand(object obj)
        {
            if (_viewModel.SelectedMatch == null)
            {
                MessageBox.Show("Bitte wählen Sie ein Spiel aus!", "Kein Spiel ausgewählt",
                                MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }
            // Check if service is available
            if (!await AdminClientHelper.IsAvailable(_adminClient))
            {
                return;
            }
            var teams = await _adminClient.GetAllTeamsAsync();

            var addBettorWindow = new AddMatchWindowController
            {
                Match     = _viewModel.SelectedMatch,
                AwayTeams = teams.ToList(),
                HomeTeams = teams.ToList()
            };

            var showMatch = addBettorWindow.ShowMatch();

            // it could be possible that the bettor is null
            if (showMatch == null)
            {
                ReloadModels();
                return;
            }
            // Check if service is available
            if (!await AdminClientHelper.IsAvailable(_adminClient))
            {
                return;
            }
            // add bettor
            var isUpdated = await _adminClient.UpdateMatchAsync(showMatch);

            UpdateModels(isUpdated, "Das Spiel konnte nicht geändert werden!", "Änderung fehlgeschlagen");
        }
示例#10
0
        protected override async void ExecuteChangeCommand(object obj)
        {
            if (_viewModel.SelectedTeam == null)
            {
                MessageBox.Show("Bitte wählen Sie eine Mannschaft aus!", "Keine Mannschaft ausgewählt",
                                MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }
            // Check if service is available
            if (!await AdminClientHelper.IsAvailable(_adminClient))
            {
                return;
            }
            var seasons = await _adminClient.GetSeasonsAsync();

            var seasonToTeamRelation = await _adminClient.GetAllSeasonToTeamRelationAsync();

            var result = new List <SeasonCheckBox>();

            seasons.ToList().ForEach(x =>
            {
                result.Add(new SeasonCheckBox
                {
                    Season  = x,
                    IsAdded = seasonToTeamRelation.Any(y => y.Season.Name.ToUpper().Equals(x.Name.ToUpper()) && y.Team.Name.ToUpper().Equals(_viewModel.SelectedTeam.Name.ToUpper()))
                });
            });
            var addBettorWindow = new AddTeamWindowController
            {
                Team    = _viewModel.SelectedTeam,
                Seasons = result
            };

            var showTeam = addBettorWindow.ShowTeam();

            // it could be possible that the bettor is null
            if (showTeam == null)
            {
                ReloadModels();
                return;
            }
            // Check if service is available
            if (!await AdminClientHelper.IsAvailable(_adminClient))
            {
                return;
            }
            // add bettor
            var isAdded = await _adminClient.UpdateTeamAsync(showTeam);

            var allTeamsAsync = await _adminClient.GetAllTeamsAsync();

            var team = allTeamsAsync.ToList().Find(x => x.Name.ToUpper().Equals(showTeam.Name.ToUpper()));

            addBettorWindow.Seasons.ForEach(x =>
            {
                if (x.IsAdded)
                {
                    _adminClient.AddSeasonToTeamRelation(new SeasonToTeamRelation {
                        Team = team, Season = x.Season
                    });
                }

                else
                {
                    _adminClient.DeleteSeasonToTeamRelation(new SeasonToTeamRelation {
                        Team = team, Season = x.Season
                    });
                }
            });
            UpdateModels(isAdded, "Die Mannschaft konnte nicht geändert werden!", "Änderung fehlgeschlagen");
        }