public ActionResult Index(Weather weatherCountry) { if (ModelState.IsValid) { GetWeatherData data = new GetWeatherData(); // Calling a function to retrive the data from the web Service List<string> cityNames = data.GetAllCities(weatherCountry.country); if (cityNames != null) { //Transfering Data between Actions TempData["cityList"] = cityNames; Session["Country"] = weatherCountry.country; return RedirectToAction("GetTheWeatherOfCity"); } return RedirectToAction("ErrorPage"); } return View(); }
public ActionResult GetTheWeatherOfCity(FormCollection form) { if (ModelState.IsValid) { var country = Session["Country"] as string; var city = form["dropDownList"].ToString(); GetWeatherData data = new GetWeatherData(); // Calling a function to get the weather of the city and country selected WeatherReport obj = data.GetTheWeather(city,country); // Proceed futher only if the object of the model is not null else direct to the error page. if (obj != null) { TempData["DataSet"] = obj; return RedirectToAction("WeatherReport"); } return RedirectToAction("ErrorPage"); } return View(); }