private void button_Click(object sender, RoutedEventArgs e) { HttpClient client = new HttpClient(); client.BaseAddress = new Uri(@"http://localhost:8080/"); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); ClassLibrary1.Team sendTeam = new ClassLibrary1.Team(); sendTeam.name = textTeamName.Text; sendTeam.city = textTeamCity.Text; sendTeam.league = textTeamLeague.Text; var content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(sendTeam), Encoding.UTF8, "application/json"); HttpResponseMessage response = client.PostAsync($"Liga/teams", content).Result; if (response.IsSuccessStatusCode) { MessageBox.Show("Succefully added new team"); this.NavigationService.Navigate(new MainPage()); } else { MessageBox.Show("Error - couldn't add new team"); return; } }
public EditGoal(ClassLibrary1.Goal editGoal, ClassLibrary1.Team selectedTeam) { if (editGoal != null) { InitializeComponent(); this.editGoal = editGoal; this.selectedTeam = selectedTeam; comboBox1.ItemsSource = selectedTeam.footballers; textBoxTime.Text = editGoal.time.TimeOfDay.ToString(); textBoxCity.Text = editGoal.teamName.ToString(); } else { MessageBox.Show("Couldn't load this match"); //this.NavigationService.Navigate(new MainPage()); return; } }
public AddMatch(ClassLibrary1.Team selectedTeam) { this.selectedTeam = selectedTeam; InitializeComponent(); HttpClient client = new HttpClient(); client.BaseAddress = new System.Uri(@"http://localhost:8080/"); // var content = new StringContent(Newtonsoft.Json.JsonConvert.DeserializeObject(selectedTeam), Encoding.UTF8, "application/json"); HttpResponseMessage response = client.GetAsync($"Liga/teams/").Result; if (response.IsSuccessStatusCode) { comboBox.ItemsSource = Newtonsoft.Json.JsonConvert.DeserializeObject <List <ClassLibrary1.Team> >(response.Content.ReadAsStringAsync().Result); comboBox1.ItemsSource = Newtonsoft.Json.JsonConvert.DeserializeObject <List <ClassLibrary1.Team> >(response.Content.ReadAsStringAsync().Result); } else { MessageBox.Show("Error - couldn't load any Teams"); } }
private void listBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { this.selectedTeam = (ClassLibrary1.Team)listBox.SelectedItem; }
public Footballer(ClassLibrary1.Team selectedTeam) { this.selectedTeam = selectedTeam; InitializeComponent(); }