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"); }
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"); }