public async Task <IActionResult> SaveCity(WeatherBindingModel model) { if (!ModelState.IsValid) { return(View()); } var accessToken = await _httpContextWrapper.GetTokenAsync(Constants.AccessToken, HttpContext); var weatherDto = await _apiClient.SaveCity(model.City, accessToken); var weatherViewModel = _mapper.Map <WeatherViewModel>(weatherDto); return(View(weatherViewModel)); }
public async Task <IActionResult> City(WeatherBindingModel model) { if (!ModelState.IsValid) { return(View()); } var weatherDto = await _apiClient.GetWeather(model.City); var weatherViewModel = _mapper.Map <WeatherViewModel>(weatherDto); return(View(new CityWeatherModel { WeatherViewModel = weatherViewModel })); }
public async Task <IActionResult> Delete(WeatherBindingModel model) { if (!ModelState.IsValid) { return(View(nameof(Index))); } var accessToken = await _httpContextWrapper.GetTokenAsync(Constants.AccessToken, HttpContext); var updatedWeather = await _apiClient.DeleteCity(model.City, accessToken); var updatedWeatherViewModel = _mapper.Map <ICollection <WeatherViewModel> >(updatedWeather); return(View(nameof(Index), new WeatherModel { WeatherViewModels = updatedWeatherViewModel })); }