コード例 #1
0
 public ActionResult DetallesArticulo(int id)
 {
     using (var db = new ProductosContexts())
     {
         articulo art = db.articulo.Find(id);
         return(View(art));
     }
 }
コード例 #2
0
        // GET: Productos
        public ActionResult Index()
        {
            ProductosContexts db = new ProductosContexts();

            //List<articulo> lista = db.articulo.Where(a => a.cant < 10).ToList();

            return(View(db.articulo.ToList()));
        }
コード例 #3
0
 public ActionResult Borrar(int id)
 {
     using (var db = new ProductosContexts())
     {
         articulo art = db.articulo.Find(id);
         db.articulo.Remove(art);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
 }
コード例 #4
0
        public ActionResult Editar(articulo a)
        {
            try
            {
                using (var db = new ProductosContexts())
                {
                    articulo art = db.articulo.Find(a.codigo);
                    art.cant   = a.cant;
                    art.nombre = a.nombre;

                    db.SaveChanges();

                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #5
0
        public ActionResult Editar(int id)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            try
            {
                using (var db = new ProductosContexts())
                {
                    //articulo ar = db.articulo.Where(a => a.codigo == id).FirstOrDefault();
                    articulo art = db.articulo.Find(id);
                    //db.SaveChanges();

                    return(View(art));
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #6
0
        public ActionResult Agregar(articulo a)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            try
            {
                using (ProductosContexts db = new ProductosContexts())
                {
                    db.articulo.Add(a);
                    db.SaveChanges();

                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("Error al agregar", ex);
                return(View());
            }
        }