private void Add_Click(object sender, RoutedEventArgs e) { OlympResult newType = new OlympResult(); GetPropForSelectedService getService = new GetPropForSelectedService(); newType.OlympID = getService.GetOlympiads().FirstOrDefault(x => x.Date == (OlympiadComboBox.SelectedItem as Olympiad).Date).ID; newType.SportTypeID = getService.GetSportTypes().FirstOrDefault(x => x.Name == (OlympiadComboBox.SelectedItem as SportType).Name).ID; newType.PersonID = getService.GetPersons().FirstOrDefault(x => x.FirstName == (OlympiadComboBox.SelectedItem as Person).FirstName && x.SecondName == (OlympiadComboBox.SelectedItem as Person).SecondName && x.ThirdName == (OlympiadComboBox.SelectedItem as Person).ThirdName).ID; newType.Place = Convert.ToInt32(PlaceTextBox.Text); foreach (var or in getService.GetOlympsResult()) { if (or.Olympiad.Date == newType.Olympiad.Date) { if (or.SportType.Name == newType.SportType.Name) { //if(or.City.Name == newType.City.Name) if (or.Person.FirstName == newType.Person.FirstName) { if (or.Person.SecondName == newType.Person.SecondName) { if (or.Person.ThirdName == newType.Person.ThirdName) { if (or.Place == newType.Place) { MessageBox.Show("This node alredy exist."); return; } } } } } } } AddingService addService = new AddingService(); addService.AddOlympiadResultNode(newType); MessageBox.Show("New result node adding."); }
public AddOlympResultNode() { InitializeComponent(); GetPropForSelectedService getService = new GetPropForSelectedService(); Olympiads = RemakeOlymp(getService.GetOlympiads()); SportTypes = getService.GetSportTypes(); //Cities = getService.GetCities(); Persons = getService.GetPersons(); DataCheck(); OlympiadComboBox.ItemsSource = Olympiads; SportTypeComboBox.ItemsSource = SportTypes; PersonComboBox.ItemsSource = Persons; this.DataContext = this; }
private void Button_Click(object sender, RoutedEventArgs e) { SportType newType = new SportType(); newType.Name = Name_; GetPropForSelectedService GettingService = new GetPropForSelectedService(); foreach (var type in GettingService.GetSportTypes()) { if (type.Name == Name_) { MessageBox.Show($"{Name_} type alredy exists."); return; } } AddingService service = new AddingService(); service.AddSportType(newType); MessageBox.Show("New sport type added."); }