public ActionResult Create(address address) { if (ModelState.IsValid) { db.addresses.Add(address); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.country_id = new SelectList(db.countries, "country_id", "country_name", address.country_id); //ViewBag.state_id = new SelectList(db.states, "state_id", "state_name", address.state_id); return View(address); }
public ActionResult Edit(address address) { if (ModelState.IsValid) { db.Entry(address).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.country_id = new SelectList(db.countries, "country_id", "country_name", address.country_id); ViewBag.state_id = new SelectList(db.states, "state_id", "state_name", address.state_id); return View(address); }