public async Task <ViewResult> Index(WeatherInputModel inputModel) { if (ModelState.IsValid) { HttpResponseMessage reponse = await _openWeatherHttpService.SendRequest(_serviceUrl, inputModel.Country, inputModel.City); if (reponse.StatusCode == HttpStatusCode.BadRequest) { return(View("Error", new ErrorModel { Input = inputModel, Message = Resources.InvalidInputData })); } if (!reponse.IsSuccessStatusCode) { return(View("Error", new ErrorModel { Input = inputModel, Message = Resources.UnexpectedError })); } WeatherDetails weather = await _openWeatherHttpService.GetData(reponse.Content); WeatherDetailsModel model = Mapper.Map <WeatherDetailsModel>(weather); model.ShowDetails = true; return(View("Details", model)); } return(View(inputModel)); }
public ActionResult Post(WeatherInputModel model) { if (!this.ModelState.IsValid) { return(this.BadRequest()); } var data = this.weatherService.GetCurrentWeather(model.Lat, model.Lon); return(this.Ok(data)); }