Exemplo n.º 1
0
        public async static Task <List <Prediction> > getPredictions(string routeID)
        {
            if (Database.predictionsLoaded)
            {
                return(Database.predictionList);
            }
            string url      = globalURL + "/predictions?filter[route]=" + routeID;
            string response = await DataFetcher.fetchData(url);

            PredictionList    raw_data       = JsonConvert.DeserializeObject <PredictionList>(response);
            List <Prediction> predictionList = new List <Prediction>();

            for (int i = 0; i < raw_data.data.Length; i++)
            {
                Prediction prediction = raw_data.data[i];
                predictionList.Add(prediction);
            }
            Database.predictionsLoaded = true;
            return(predictionList);
        }