Exemplo n.º 1
0
        public static List <Results> MergeResults(ListResultAPI res)
        {
            List <Results> results = new List <Results>();


            List <string> dummynames = new List <string>();
            List <string> names      = new List <string>();

            dummynames = res.data.Select(p => p.eve).ToList();
            names      = dummynames.Distinct().ToList();

            res.data.GroupBy(n => n.eve);

            for (int i = 0; i < names.Count; i++)
            {
                List <Team> teams  = new List <Team>();
                Results     result = new Results();

                foreach (ResultAPI resultapi in res.data)
                {
                    if (names[i] == resultapi.eve)
                    {
                        Team team = new Team();
                        team.Teamid   = resultapi.tid;
                        team.Round    = resultapi.round;
                        team.Position = resultapi.pos;
                        teams.Add(team);
                    }
                }
                result.EventName = names[i];
                result.Image     = "ms-appx:///Assets/Square150x150Logo.scale-200.png";
                result.Teams     = teams;

                results.Add(result);
            }

            return(results);
        }
Exemplo n.º 2
0
        private async Task <List <Results> > GetResultsAsync()
        {
            List <Results> res = new List <Results>();

            using (HttpClient client = new HttpClient())
            {
                try
                {
                    ListResultAPI listres  = new ListResultAPI();
                    var           response = await client.GetStringAsync("http://api.mitportals.in/results");

                    listres = JsonConvert.DeserializeObject <ListResultAPI>(response);

                    res = App.MergeResults(listres);
                }
                catch
                {
                    //Do Nothing
                }

                return(res);
            }
        }