public async Task <ActionResult> DeleteConfirmed(int id) { ELEMENTO eLEMENTO = await db.ELEMENTO.FindAsync(id); db.ELEMENTO.Remove(eLEMENTO); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
//**************** //CONSTRUCTOR public CrudVM(Accion accion) { _accion = accion; ListaCategorias = BbddService.GetCategorias(); if (_accion == Accion.Nuevo) { ElementoSeleccionado = new ELEMENTO(); ElementoSeleccionado.ImagenElementoURL = ""; } }
public async Task <ActionResult> Edit([Bind(Include = "id_elem,elem_ref,elem_nom,categoria,Proveedor")] ELEMENTO eLEMENTO) { if (ModelState.IsValid) { db.Entry(eLEMENTO).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.categoria = new SelectList(db.CATEGORIA, "id_categoria", "nombre", eLEMENTO.categoria); ViewBag.Proveedor = new SelectList(db.PROVEEDOR, "id_proveedor", "pro_nombre", eLEMENTO.Proveedor); return(View(eLEMENTO)); }
public static bool ExisteElemento(ELEMENTO item) { var consulta = from n in _contexto.ELEMENTOS where n.NombreElemento == item.NombreElemento select n; if (consulta.Count() <= 0) { return(false); } return(true); }
// GET: ELEMENTOS/Details/5 public async Task <ActionResult> Details(int?id) { if (Session["User"] != null) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ELEMENTO eLEMENTO = await db.ELEMENTO.FindAsync(id); if (eLEMENTO == null) { return(HttpNotFound()); } return(View(eLEMENTO)); } return(RedirectToAction("index", "Home")); }
// GET: ELEMENTOS/Edit/5 public async Task <ActionResult> Edit(int?id) { if (Session["User"] != null) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ELEMENTO eLEMENTO = await db.ELEMENTO.FindAsync(id); if (eLEMENTO == null) { return(HttpNotFound()); } ViewBag.categoria = new SelectList(db.CATEGORIA, "id_categoria", "nombre", eLEMENTO.categoria); ViewBag.Proveedor = new SelectList(db.PROVEEDOR, "id_proveedor", "pro_nombre", eLEMENTO.Proveedor); return(View(eLEMENTO)); } return(RedirectToAction("index", "Home")); }
public void LimpiaCampos() { ElementoSeleccionado = new ELEMENTO(); }
public static int DeleteElemento(ELEMENTO item) { _contexto.ELEMENTOS.Remove(item); return(_contexto.SaveChanges()); }
public static int AddElemento(ELEMENTO item) { _contexto.ELEMENTOS.Add(item); return(_contexto.SaveChanges()); }