public ActionResult GetWeatherByCity(FormCollection FC) { string cityname = FC["txtCityName"]; repo = new WeatherTodayRepo(); List <GETWEATHERBYCITY_Result> entityWeatherList = repo.GetWeatherByCity(cityname); List <Models.WeatherDetail> modelWeatherList = new List <Models.WeatherDetail>(); foreach (var dalWeather in entityWeatherList) { Models.WeatherDetail modelWeather = new Models.WeatherDetail(); modelWeather.CityID = dalWeather.CityID; modelWeather.CityName = dalWeather.CityName; modelWeather.CountryName = dalWeather.CountryName; modelWeather.Temperature = dalWeather.Temperature; modelWeather.Humidity = dalWeather.Humidity; modelWeather.Visibility = dalWeather.Visibility; modelWeatherList.Add(modelWeather); } if (modelWeatherList != null && modelWeatherList.Count == 0) { ViewBag.Msg = "No records found"; } return(View("GetWeatherByCityPost", modelWeatherList)); }
public ActionResult CreateWeather(Models.WeatherDetail weatherdetails) { if (ModelState.IsValid) { repo = new WeatherTodayRepo(); WeatherDetail entityWeather = new WeatherDetail(); entityWeather.CityID = weatherdetails.CityID; entityWeather.CityName = weatherdetails.CityName; entityWeather.CountryName = weatherdetails.CountryName; entityWeather.Temperature = weatherdetails.Temperature; entityWeather.Humidity = weatherdetails.Humidity; entityWeather.Visibility = weatherdetails.Visibility; bool status = repo.AddWeatherDetails(entityWeather); if (status) { ViewBag.Msg = "Weather details added successfully"; } else { ViewBag.Msg = "Something went wrong"; } } return(View(weatherdetails)); }
public ActionResult UpdateWeather(Models.WeatherDetail Wd) { if (ModelState.IsValid) { WeatherDetail entityWeather = new WeatherDetail(); entityWeather.CityID = Wd.CityID; entityWeather.CityName = Wd.CityName; entityWeather.CountryName = Wd.CountryName; entityWeather.Temperature = Wd.Temperature; entityWeather.Humidity = Wd.Humidity; entityWeather.Visibility = Wd.Visibility; repo = new WeatherTodayRepo(); bool status = repo.UpdateWeatherDetails(entityWeather); if (status) { Session["CityId"] = null; return(RedirectToAction("ViewAllCityWeatherList", "Weather")); } else { ViewBag.Msg = "Something went wrong"; } } return(View()); }
public ActionResult UpdateProfile() { Models.UserDetail modelUser = new Models.UserDetail(); repo = new WeatherTodayRepo(); UserDetail entityUser = repo.GetUserByEmail(Session["EmailID"].ToString()); modelUser.User_ID = entityUser.User_ID; modelUser.User_First_Name = entityUser.User_First_Name; modelUser.User_Last_Name = entityUser.User_Last_Name; modelUser.User_Emaild = entityUser.User_Emaild; modelUser.User_Password = entityUser.User_Password; return(View(modelUser)); }
public ActionResult UpdateWeather(int CityId) { repo = new WeatherTodayRepo(); WeatherDetail entityWeather = repo.GetWeatherDetailsByCityID(CityId); Models.WeatherDetail modelWeather = new Models.WeatherDetail(); modelWeather.CityID = entityWeather.CityID; modelWeather.CityName = entityWeather.CityName; modelWeather.CountryName = entityWeather.CountryName; modelWeather.Temperature = entityWeather.Temperature; modelWeather.Humidity = entityWeather.Humidity; modelWeather.Visibility = entityWeather.Visibility; return(View(modelWeather)); }
public ActionResult LoginUser(string uEmail, string uPass) { repo = new WeatherTodayRepo(); string email = repo.ValidateUser(uEmail, uPass); if ((uEmail != null) && (email == uEmail)) { Session["EmailID"] = uEmail; return(RedirectToAction("ViewAllCityWeatherList", "Weather")); } else { ViewBag.Msg = "Invalid credentials. Please enter correct email and password."; } return(View()); }
public ActionResult RemoveWeather() { repo = new WeatherTodayRepo(); bool status = repo.DeleteWeatherDetails(Convert.ToInt32(Session["CityId"].ToString())); if (status) { Session["CityId"] = null; return(RedirectToAction("ViewAllCityWeatherList", "Weather")); } else { ViewBag.Msg = "Something went wrong"; } return(View()); }
public ActionResult ViewAllCityWeatherList() { repo = new WeatherTodayRepo(); List <GETALLCITYWEATHER_Result> gCity = repo.ViewAllCityWeatherList(); List <Models.WeatherDetail> modelWeatherList = new List <Models.WeatherDetail>(); foreach (var item in gCity) { Models.WeatherDetail modelWeather = new Models.WeatherDetail(); modelWeather.CityID = item.CityID; modelWeather.CityName = item.CityName; modelWeather.CountryName = item.CountryName; modelWeather.Temperature = item.Temperature; modelWeather.Humidity = item.Humidity; modelWeather.Visibility = item.Visibility; modelWeatherList.Add(modelWeather); } return(View(modelWeatherList)); }
public ActionResult UpdateProfile(Models.UserDetail Ud) { UserDetail entityUser = new UserDetail(); entityUser.User_ID = Ud.User_ID; entityUser.User_First_Name = Ud.User_First_Name; entityUser.User_Last_Name = Ud.User_Last_Name; entityUser.User_Emaild = Ud.User_Emaild; entityUser.User_Password = Ud.User_Password; repo = new WeatherTodayRepo(); bool status = repo.UpdateUserDetails(entityUser); if (status) { ViewBag.Msg = " Your details are updated successfully"; } else { ViewBag.Msg = "Something went wrong"; } return(View()); }
public ActionResult CreateUser(Models.UserDetail ud) { repo = new WeatherTodayRepo(); UserDetail entityUser = new UserDetail(); entityUser.User_ID = ud.User_ID; entityUser.User_First_Name = ud.User_First_Name; entityUser.User_Last_Name = ud.User_Last_Name; entityUser.User_Emaild = ud.User_Emaild; entityUser.User_Password = ud.User_Password; bool status = repo.AddUser(entityUser); if (status) { return(RedirectToAction("LoginUser", "User")); } else { ViewBag.Msg = "Something went wrong."; } return(View(ud)); }