Esempio n. 1
0
        /// <summary>
        /// Sends an API request and collects the data
        /// </summary>
        private async Task GetAPIData()
        {
            // Send an API request
            var apiResult = await WebRequests.PostAsync <APIWeatherResponse>(GetAPIRoute(), CityName);

            // If we got a data back...
            if (apiResult != null && apiResult.Successful && apiResult.ServerResponse != null)
            {
                // Deserialize json to suitable view model
                APIResponse = apiResult.ServerResponse;
            }
        }
Esempio n. 2
0
        public IActionResult GetWeatherForCity([FromBody] string city)
        {
            // Check if we have info about this city in database

            // Check if city exists
            var geoResponse = _geo.GetAddressLocation(city);

            // If it does not
            if (false /*!city.DoesExist*/)
            {
                return(NotFound());
            }

            // Get weather from Onet

            // Get weather from XXX

            // Get weather from YYY

            // Create response object
            var response = new APIWeatherResponse
            {
                WeatherInformationsList = new List <WeatherInformationAPIModel>
                {
                    new WeatherInformationAPIModel
                    {
                        WeatherProviderAPIName = "Onet",
                        Celsius = 20,
                    },
                    new WeatherInformationAPIModel
                    {
                        WeatherProviderAPIName = "WP",
                        Celsius = 21,
                    },
                    new WeatherInformationAPIModel
                    {
                        WeatherProviderAPIName = "Onet",
                        Celsius = 18,
                    },
                    new WeatherInformationAPIModel
                    {
                        WeatherProviderAPIName = "WP",
                        Celsius = 11,
                    }
                }
            };

            // Return successful response with data
            return(Ok(response));
        }