// // GET: /Zone/ public ActionResult Index() { ZONE _zone = new ZONE(); List<Zone> _list = new List<Zone>(); ; foreach (ZONE item in ZONE.GetList()) { Zone zones = new Zone(); zones.NOM = item.NOM; zones.CONTROLEUR = item.CONTROLEUR; zones.ID_CONT = item.ID_CONTROLER; zones.ID_AUTO = item.ID_AUTO; _list.Add(zones); } return View(_list); }
// // GET: /Zone/Edit/5 public ActionResult Edit() { Zone zones = new Zone(); ZONE _zone = new ZONE(); int id = Int32.Parse(RouteData.Values["id"].ToString()); _zone.LoadId(id); zones.NOM = _zone.NOM; zones.CONTROLEUR = _zone.CONTROLEUR; IEnumerable<SelectListItem> list = ToSelectListItems(); list.ToList().Find(x => x.Text.Equals(zones.CONTROLEUR)).Selected = true; ViewData["ID_CONT"] = list; return View(zones); }
public ActionResult Create(Zone zonesToCreate) { if (!ModelState.IsValid) return View(); try { ZONE _zone = new ZONE(); _zone.NOM = zonesToCreate.NOM; _zone.ID_CONTROLER = zonesToCreate.ID_CONT; _zone.Save(); return RedirectToAction("../Zone/Index"); } catch { return View(); } }
public ActionResult Delete(Zone zones) { int id = Int32.Parse(RouteData.Values["id"].ToString()); if (!ModelState.IsValid) return View(); try { ZONE _zone = new ZONE(); _zone.SetId(id); _zone.Delete(); return RedirectToAction("../Zone/Index");//reafficher l liste } catch { return View(); } }
public ActionResult Edit(Zone zones) { int id = Int32.Parse(RouteData.Values["id"].ToString()); if (!ModelState.IsValid) return View(); try { ZONE _zone = new ZONE(); _zone.NOM = zones.NOM; _zone.CONTROLEUR = zones.CONTROLEUR; _zone.ID_CONTROLER = zones.ID_CONT; _zone.SetId(id); _zone.Save(); return RedirectToAction("../Zone/Index"); } catch { return View(); } }