private void ButtonAddChallenge_OnClick(object sender, RoutedEventArgs e) { var newChallengeWindow = new NewChallengeWindow(_dataView); var dialogResult = newChallengeWindow.ShowDialog(); if (dialogResult != true) { return; } int maxChallengeId = 0; if (_dataView.AllChallenges.Count > 0) { maxChallengeId = _dataView.AllChallenges.Max(c => c.Id) + 1; } Challenge newChallenge = new Challenge { Id = maxChallengeId, TrackName = newChallengeWindow.NewChallenge.TrackName, CarName = newChallengeWindow.NewChallenge.CarName, Description = newChallengeWindow.NewChallenge.Description, Difficulty = newChallengeWindow.NewChallenge.Difficulty }; _dataView.AddChallenge(newChallenge); ChallengesComboBox.SelectedIndex = ChallengesComboBox.Items.Count - 1; UpdateFilteredChallenges(); }
private void AddAsRace_OnClick(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(ProjectCarsData?.CarName) || string.IsNullOrEmpty(ProjectCarsData.TrackLocation)) { return; } var trackName = ProjectCarsData.TrackLocation; if (!string.IsNullOrEmpty(ProjectCarsData.TrackVariant)) { trackName += " " + ProjectCarsData.TrackVariant; } _dataView.AddChallenge(new Challenge { CarName = ProjectCarsData.CarName, TrackName = trackName, Difficulty = Difficulty.Medium, Description = "Default race description." }); }