public ActionResult DeleteConfirmed(int id) { Estado_Ambientes estado_Ambientes = db.Estado_Ambientes.Find(id); db.Estado_Ambientes.Remove(estado_Ambientes); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Estado_AmbientesID,Nombre_Estado")] Estado_Ambientes estado_Ambientes) { if (ModelState.IsValid) { db.Entry(estado_Ambientes).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(estado_Ambientes)); }
// GET: Estado_Ambientes/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Estado_Ambientes estado_Ambientes = db.Estado_Ambientes.Find(id); if (estado_Ambientes == null) { return(HttpNotFound()); } return(View(estado_Ambientes)); }
public ActionResult Create([Bind(Include = "Estado_AmbientesID,Nombre_Estado")] Estado_Ambientes estado_Ambientes) { bool existEst = db.Estado_Ambientes.Any(e => e.Nombre_Estado == estado_Ambientes.Nombre_Estado); if (existEst) { ModelState.AddModelError("Nombre_Estado", "El Estado ya existe!"); } if (ModelState.IsValid) { db.Estado_Ambientes.Add(estado_Ambientes); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(estado_Ambientes)); }