Ejemplo n.º 1
0
        public ActionResult Edit(ProductoViewModel model)
        {
            try
            {
                if (ModelState.IsValid) // valida los DataAnotations
                {
                    using (wi200122_pastas_tEntities db = new wi200122_pastas_tEntities())
                    {
                        var oProducto = db.producto.Find(model.id);

                        oProducto.descripcion = model.Descripcion;
                        oProducto.fecha_alta  = DateTime.Today;

                        db.Entry(oProducto).State = System.Data.EntityState.Modified;
                        db.SaveChanges();
                    }
                }

                return(Redirect("~/Producto/"));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Ejemplo n.º 2
0
        public ActionResult Delete(int Id)
        {
            try
            {
                using (wi200122_pastas_tEntities db = new wi200122_pastas_tEntities())
                {
                    var oProducto = db.producto.Find(Id);

                    db.Entry(oProducto).State = System.Data.EntityState.Deleted;
                    db.SaveChanges();
                }

                return(Redirect("~/Producto/"));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }