public async Task <IActionResult> Index(ProvideDataViewModel viewModel) { // Get data from our API var apiData = new ShowWeatherViewModel(); // Send a request var apiResult = await WebRequests.PostAsync <ShowWeatherViewModel>(GetAPIRoute(), viewModel.CityName); // If we got a data... if (apiResult.Successful) { // Deserialize json to suitable view model apiData = apiResult.ServerResponse; } // Show the page to the user return(View(apiData)); }
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 ShowWeatherViewModel { CityName = city, WeatherInformationsList = new List <WeatherInformationViewModel> { new WeatherInformationViewModel { WeatherProviderAPIName = "Onet", Celsius = 20, }, new WeatherInformationViewModel { WeatherProviderAPIName = "WP", Celsius = 21, } } }; // Return successful response with data return(Ok(response)); }