public Footballers(ClassLibrary1.Team selectedTeam)
        {
            InitializeComponent();
            this.selectedTeam = selectedTeam;

            listBox.ItemsSource = selectedTeam.footballers;
        }
Esempio n. 2
0
        public Goals(ClassLibrary1.Match2 currentMatch, ClassLibrary1.Team selectedTeam)
        {
            InitializeComponent();
            this.currentMatch = currentMatch;
            this.selectedTeam = selectedTeam;
            var goals = new List <Goal>();

            foreach (var footballer in selectedTeam.footballers)
            {
                footballer.goals.All(x =>
                {
                    x.footballer = footballer;
                    x.match      = currentMatch;
                    x.timeString = x.time.TimeOfDay.ToString();
                    return(true);
                });
                goals.AddRange(footballer.goals);
            }

            listBox.ItemsSource = goals;

            //HttpClient client = new HttpClient();
            //client.BaseAddress = new System.Uri(@"http://localhost:8080/");
            //HttpResponseMessage response = client.GetAsync($"Liga/goals/").Result;

            //if (response.IsSuccessStatusCode)
            //{
            //    var result = Newtonsoft.Json.JsonConvert.DeserializeObject<GoalsResponse>(response.Content.ReadAsStringAsync().Result);

            //    listBox.ItemsSource = result.goals.FindAll(i => i.teamName==selectedTeam.name);

            //}
            //else
            //    MessageBox.Show("Error - couldn't load any goals");
        }
Esempio n. 3
0
        public Matches(ClassLibrary1.Team selectedTeam)
        {
            this.selectedTeam = selectedTeam;
            InitializeComponent();

            HttpClient client = new HttpClient();

            client.BaseAddress = new System.Uri(@"http://localhost:8080/");
            HttpResponseMessage response = client.GetAsync($"Liga/matches/").Result;

            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

            if (response.IsSuccessStatusCode)
            {
                RootObject result = JsonConvert.DeserializeObject <RootObject>(response.Content.ReadAsStringAsync().Result);
                if (result != null)
                {
                    listBox.ItemsSource       = result.matches.FindAll(i => ((i.hostTeam.name == selectedTeam.name) || (i.guestTeam.name == selectedTeam.name)));
                    listBox.DisplayMemberPath = "date";
                }
            }
            else
            {
                MessageBox.Show("Error - couldn't load any Teams");
            }
        }
Esempio n. 4
0
        public Team(ClassLibrary1.Team selectedTeam)
        {
            InitializeComponent();
            this.selectedTeam = selectedTeam;

            HttpClient client = new HttpClient();

            client.BaseAddress = new Uri(@"http://localhost:8080/");
            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

            textBoxName.Text   = selectedTeam.name;
            textBoxCity.Text   = selectedTeam.city;
            textBoxLeague.Text = selectedTeam.league;
        }
Esempio n. 5
0
        public AddGoal(ClassLibrary1.Match2 selectedMatch, ClassLibrary1.Team selectedTeam)
        {
            InitializeComponent();
            this.currentMatch = selectedMatch;
            this.selectedTeam = selectedTeam;

            //HttpClient client = new HttpClient();
            //client.BaseAddress = new System.Uri(@"http://localhost:8080/");

            textBoxName.Text      = selectedTeam.name.ToString();
            comboBox1.ItemsSource = selectedTeam.footballers;

            /* //load teams
             * HttpResponseMessage response = client.GetAsync($"Liga/teams/").Result;
             * if (response.IsSuccessStatusCode)
             * {
             *   comboBox.ItemsSource = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClassLibrary1.Team>>(response.Content.ReadAsStringAsync().Result);
             *
             * }
             * else
             *   MessageBox.Show("Error - couldn't load any Teams");
             * //load footballers
             */
        }