public ActionResult AddUpdateCity(int id = 0) { clsCity city = new clsCity(); if (id > 0) { city = (from c in db.tblCities where c.CityId == id select new clsCity { CityId = c.CityId, CityName = c.CityName, CountryId = c.CountryId, CountryName = db.tblCountries.Where(x => x.CountryId == c.CountryId).Select(x => x.CountryName).FirstOrDefault() }).FirstOrDefault(); } else { city = new clsCity { CityId = 0, CityName = "", CountryId = 0, CountryName = "" }; } return(PartialView(city)); }
private string InsertUpdateCityDb(clsCity st, string insertUpdateStatus) { string returnId = "0"; string connection = System.Configuration.ConfigurationManager.ConnectionStrings["ADO"].ConnectionString; using (SqlConnection con = new SqlConnection(connection)) { try { con.Open(); using (SqlCommand cmd = new SqlCommand("spInsertUpdateCity", con)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Clear(); cmd.Parameters.Add("@CityId", SqlDbType.Int).Value = st.CityId; cmd.Parameters.Add("@CityName", SqlDbType.NVarChar).Value = st.CityName; cmd.Parameters.Add("@CountryId", SqlDbType.Int).Value = st.CountryId; cmd.Parameters.Add("@InsertUpdateStatus", SqlDbType.NVarChar).Value = insertUpdateStatus; cmd.Parameters.Add("@CheckReturn", SqlDbType.NVarChar, 300).Direction = ParameterDirection.Output; cmd.ExecuteNonQuery(); returnId = cmd.Parameters["@CheckReturn"].Value.ToString(); cmd.Dispose(); } con.Close(); con.Dispose(); } catch (Exception ex) { returnId = ex.Message.ToString(); } } return(returnId); }
private async void BtnSubmit_Clicked(object sender, EventArgs e) { clsCity objCity = pkrCity.SelectedItem as clsCity; OpenWeatherObj obj = await MgrHTTP.HTTPGet <OpenWeatherObj>("weather", objCity.id.ToString()); DisplayWeather(obj); }
private async void BtnSubmit_Click(object sender, EventArgs e) { if (!ValidateSubmitData()) { return; } clsCity objCity = cboCity.SelectedItem as clsCity; OpenWeatherObj obj = await MgrHTTP.HTTPGet <OpenWeatherObj>("weather", objCity.id.ToString()); DisplayWeather(obj); }
private void BtnDailyForecast_Click(object sender, EventArgs e) { if (!ValidateSubmitData()) { return; } clsCity obj = cboCity.SelectedItem as clsCity; using (frmForecast frm = new frmForecast(obj.id)) { frm.ShowDialog(); } }
private void BtnForecast_Clicked(object sender, EventArgs e) { try { clsCity objCity = pkrCity.SelectedItem as clsCity; Navigation.PushModalAsync(new ForecastPage(objCity.id)); } catch (NullReferenceException) { DisplayAlert("Error", "Please select a city first!", "OK"); } catch (Exception ex) { DisplayAlert("Error", ex.GetType().Name, "OK"); } }
public ActionResult DeleteCity(int id) { string message = ""; bool status = false; clsCity st = new clsCity(); st.CityId = id; string returnId = InsertUpdateCityDb(st, "Delete"); if (returnId == "Success") { ModelState.Clear(); status = true; message = "User Type Successfully Deleted"; } else { ModelState.Clear(); status = false; message = returnId; } return(new JsonResult { Data = new { status = status, message = message } }); //string message = ""; //bool status = false; //try //{ // var result = db.tblCities.Single(city => city.CityId == id); // db.tblCities.Remove(result); // db.SaveChanges(); //} //catch(Exception ex) //{ // message = ex.Message.ToString(); //} //return new JsonResult { Data = new { status = status, message = message } }; }
public ActionResult InsertUpdateCity(clsCity city) { string message = ""; bool status = false; try { string returnId = "0"; string insertUpdateStatus = ""; if (city.CityId > 0) { insertUpdateStatus = "Update"; } else { insertUpdateStatus = "Save"; } returnId = InsertUpdateLocationTypeDb(city, insertUpdateStatus); if (returnId == "Success") { status = true; message = "User Type Successfully Updated"; } else { ModelState.Clear(); status = false; message = returnId; } } catch (Exception ex) { status = false; message = ex.Message.ToString(); } return(new JsonResult { Data = new { status = status, message = message } }); }