Example #1
0
        /// <summary>
        /// Fetches JSON data from API an converts to regular model
        /// </summary>
        /// <returns>List of TidalStation's</returns>
        public List <TidalStation> FetchStations()
        {
            string response = GetInstance().GetStationsJSON();

            Newton.TidalStationsNewton model = JsonConvert.DeserializeObject <Newton.TidalStationsNewton>(response);
            return(NewtonModelsConverter.TidalStationsNewton_ToList_TidalStation(model));
        }
Example #2
0
        /// <summary>
        /// Converts JSON model to list of TidalStation models
        /// </summary>
        /// <param name="data">Instance to convert from</param>
        /// <returns>List of TidalStation's</returns>
        public static List <TidalStation> TidalStationsNewton_ToList_TidalStation(Newton.TidalStationsNewton data)
        {
            List <TidalStation> result = new List <TidalStation>();

            if (data != null)
            {
                foreach (Newton.Feature f in data.features)
                {
                    result.Add(new TidalStation(f.properties.Id, f.geometry.coordinates[1],
                                                f.geometry.coordinates[0], f.properties.Name, f.properties.Country));
                }
            }

            return(result);
        }