public ActionResult Create(FormCollection formCollection) { List <SelectListItem> selectlistitems = new List <SelectListItem>(); List <SelectListItem> countryselectlistitems = new List <SelectListItem>(); stateBusinessLayer StateBusinessLayer = new stateBusinessLayer(); CountryBusinessLayer countryBusinessLayer = new CountryBusinessLayer(); foreach (state State in StateBusinessLayer.States.Where(x => x.CountryId == Convert.ToInt64(formCollection["countries"]))) { SelectListItem selectListItem = new SelectListItem { Text = State.State, Value = State.Id.ToString(), }; selectlistitems.Add(selectListItem); } foreach (Country country in countryBusinessLayer.countries) { SelectListItem selectListItem1 = new SelectListItem { Text = country.CountryName, Value = country.Id.ToString(), Selected = (country.Id == Convert.ToInt64(formCollection["countries"]) ? true : false) }; countryselectlistitems.Add(selectListItem1); } //ViewBag.countries = new SelectList(countryBusinessLayer.countries.ToList(), "Id", "CountryName", formCollection["countries"]); ViewBag.States = new SelectList(selectlistitems, "Value", "Text"); return(View()); }
public ActionResult Create() { CountryBusinessLayer countryBusinessLayer = new CountryBusinessLayer(); ViewBag.Countries = new SelectList(countryBusinessLayer.countries, "Id", "CountryName"); return(View()); }
public ActionResult Delete(Int64 id) { CountryBusinessLayer db = new CountryBusinessLayer(); Country country = db.countries.SingleOrDefault(x => x.Id == id); Session["DeleteId"] = id; return(View(country)); }
// GET: country public ActionResult Index() { //PayrollContext db = new PayrollContext(); CountryBusinessLayer countryBusinessLayer = new CountryBusinessLayer(); List <Country> countries = countryBusinessLayer.countries.ToList(); //List<country> Countries = db.Country.ToList(); return(View(countries)); }
public ActionResult Delete(Int64 id) { stateBusinessLayer StateBusinessLayer = new stateBusinessLayer(); state State = StateBusinessLayer.States.Single(x => x.Id == id); ConfigurationManager.AppSettings["EditId"] = id.ToString(); CountryBusinessLayer countryBusinessLayer = new CountryBusinessLayer(); Country country = countryBusinessLayer.countries.Single(x => x.Id == State.CountryId); State.CountryName = country.CountryName; return(View(State)); }
public ActionResult Delete(FormCollection formcollection) { CountryBusinessLayer countryBusinessLayer = new CountryBusinessLayer(); Country country = new Country(); country.Id = Convert.ToInt64(Session["DeleteId"].ToString()); int rv = countryBusinessLayer.DeleteCountry(country); if (rv != 0 && rv != -1) { return(RedirectToAction("Index")); } return(View()); }
public ActionResult Create(FormCollection formcollection) { Country country = new Country(); country.CountryName = formcollection["CountryName"]; CountryBusinessLayer countryBusinessLayer = new CountryBusinessLayer(); int rv = countryBusinessLayer.AddCountry(country); if (rv != 0 && rv != -1) { return(RedirectToAction("Index")); } return(View()); }
public ActionResult Edit(FormCollection formcollection) { CountryBusinessLayer countryBusinessLayer = new CountryBusinessLayer(); Country country = new Country(); country.CountryName = formcollection["CountryName"]; countryBusinessLayer.Id = Convert.ToInt64(Session["EditId"].ToString()); int rv = countryBusinessLayer.UpdateCountry(country); if (rv != 0 && rv != -1) { return(RedirectToAction("Index")); } return(View()); }
public ActionResult Edit(Int64 id) { stateBusinessLayer StateBusinessLayer = new stateBusinessLayer(); state State = StateBusinessLayer.States.Single(x => x.Id == id); ConfigurationManager.AppSettings["EditId"] = id.ToString(); CountryBusinessLayer countryBusinessLayer = new CountryBusinessLayer(); List <SelectListItem> selectlistitems = new List <SelectListItem>(); foreach (Country country in countryBusinessLayer.countries) { SelectListItem selectListItem = new SelectListItem { Text = country.CountryName, Value = country.Id.ToString(), Selected = country.Id == State.CountryId ? true : false }; selectlistitems.Add(selectListItem); } ViewBag.countries = selectlistitems; return(View(State)); }