public ActionResult Create(t_wilayah t_wilayah) { if (ModelState.IsValid) { using (var db = new db_esosEntities()) { var create = db.t_wilayah.Create(); create.geo_location = t_wilayah.geo_location; create.parent_id = 0; create.web_url = t_wilayah.web_url; create.wil_address = t_wilayah.wil_address; create.wil_name = t_wilayah.wil_name; create.wil_phone = t_wilayah.wil_phone; create.wil_type = "Kecamatan"; create.wil_email = t_wilayah.wil_email; db.t_wilayah.Add(create); db.SaveChanges(); return(RedirectToAction("Index")); } } return(View(t_wilayah)); }
public ActionResult Create(t_wilayah t_wilayah) { if (ModelState.IsValid) { using (var db = new db_esosEntities()) { var create = db.t_wilayah.Create(); create.geo_location = t_wilayah.geo_location; create.parent_id = t_wilayah.parent_id; create.web_url = t_wilayah.web_url; create.wil_address = t_wilayah.wil_address; create.wil_name = t_wilayah.wil_name; create.wil_phone = t_wilayah.wil_phone; create.wil_type = "Kelurahan"; create.wil_email = t_wilayah.wil_email; db.t_wilayah.Add(create); db.SaveChanges(); return(RedirectToAction("Index")); } } else { ViewBag.parent_id = new SelectList((from table in db.t_wilayah where table.wil_type == "Kecamatan" select table).ToList(), "wil_id", "wil_name"); return(View(t_wilayah)); } }
public ActionResult Edit(int id, t_wilayah wilayah) { if (ModelState.IsValid) { using (db) { t_wilayah t_wilayah = db.t_wilayah.Find(id); t_wilayah.geo_location = wilayah.geo_location; t_wilayah.parent_id = wilayah.parent_id; t_wilayah.web_url = wilayah.web_url; t_wilayah.wil_address = wilayah.wil_address; t_wilayah.wil_name = wilayah.wil_name; t_wilayah.wil_phone = wilayah.wil_phone; t_wilayah.wil_type = "Kelurahan"; t_wilayah.wil_email = wilayah.wil_email; db.SaveChanges(); return(RedirectToAction("Index")); } } else { ViewBag.parent_id = new SelectList((from table in db.t_wilayah where table.wil_type == "Kecamatan" select table).ToList(), "wil_id", "wil_name"); return(View(wilayah)); } }
public ActionResult DeleteConfirmed(long id) { t_wilayah t_wilayah = db.t_wilayah.Find(id); db.t_wilayah.Remove(t_wilayah); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(t_wilayah t_wilayah) { if (ModelState.IsValid) { db.Entry(t_wilayah).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(t_wilayah)); }
public ActionResult Edit(long id = 0) { t_wilayah t_wilayah = db.t_wilayah.Find(id); if (t_wilayah == null) { return(HttpNotFound()); } return(View(t_wilayah)); }
public ActionResult Edit(long id = 0) { t_wilayah t_wilayah = db.t_wilayah.Find(id); ViewBag.parent_id = new SelectList((from table in db.t_wilayah where table.wil_type == "Kecamatan" select table).ToList(), "wil_id", "wil_name"); if (t_wilayah == null) { return(HttpNotFound()); } return(View(t_wilayah)); }
public ActionResult Details(long id = 0) { t_wilayah t_wilayah = db.t_wilayah.Find(id); var parent = (from table in db.t_wilayah where table.wil_id == id select table.parent_id).FirstOrDefault(); ViewBag.kecamatan = (from table in db.t_wilayah where table.wil_id == parent select table.wil_name).FirstOrDefault(); if (t_wilayah == null) { return(HttpNotFound()); } return(View(t_wilayah)); }