// GET: Cities/Create public ActionResult Create() { ViewBag.DpeartmentId = new SelectList( Comboshelper.GetDepartments(), "DpeartmentId", "name"); return(View()); }
public ActionResult Edit([Bind(Include = "CityId,name,DpeartmentId")] City city) { if (ModelState.IsValid) { db.Entry(city).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.DpeartmentId = new SelectList( Comboshelper.GetDepartments(), "DpeartmentId", "name", city.DpeartmentId); return(View(city)); }
public ActionResult Create([Bind(Include = "CityId,name,DpeartmentId")] City city) { if (ModelState.IsValid) { db.Cities.Add(city); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.DpeartmentId = new SelectList( Comboshelper.GetDepartments(), "DpeartmentId", "name", city.DpeartmentId); return(View(city)); }
// GET: Cities/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } City city = db.Cities.Find(id); if (city == null) { return(HttpNotFound()); } ViewBag.DpeartmentId = new SelectList( Comboshelper.GetDepartments(), "DpeartmentId", "name", city.DpeartmentId); return(View(city)); }