Пример #1
0
        public ActionResult Delete(int id)
        {
            tb_categorias regCat = data.tb_categorias.Where(c => c.idcate == id).First();

            data.tb_categorias.Remove(regCat);

            data.SaveChanges();

            return(RedirectToAction("Index"));
        }
Пример #2
0
        public ActionResult Create(tb_categorias objCat)
        {
            if (!ModelState.IsValid)
            {
                return(View(new tb_categorias()));
            }

            data.tb_categorias.Add(objCat);
            data.SaveChanges();

            return(RedirectToAction("Index"));
        }
Пример #3
0
        public ActionResult Desactivar(int id)
        {
            tb_categorias regCat = data.tb_categorias.Where(c => c.idcate == id).First();

            if (regCat.estado == "A")
            {
                regCat.estado = "I";
            }
            else
            {
                regCat.estado = "A";
            }

            data.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #4
0
        public ActionResult Edit(tb_categorias objCat)
        {
            if (!ModelState.IsValid)
            {
                return(View(objCat));
            }

            tb_categorias regCat = data.tb_categorias.Where(c => c.idcate == objCat.idcate).First();

            regCat.nomcate     = objCat.nomcate;
            regCat.descripcion = objCat.descripcion;
            regCat.estado      = objCat.estado;

            data.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #5
0
        public ActionResult Details(int id)
        {
            tb_categorias regCat = data.tb_categorias.Where(c => c.idcate == id).First();

            return(View(regCat));
        }