public ActionResult EditarP(ProductosViewModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    using (TredaEntities db = new TredaEntities())
                    {
                        var oTabla = db.Productos.Find(model.SKU);
                        oTabla.Nombre      = model.Nombre;
                        oTabla.Descripcion = model.Descripcion;
                        oTabla.Valor       = model.Valor;
                        oTabla.Tienda      = model.Tienda;
                        oTabla.Imagen      = model.Imagen;

                        db.Entry(oTabla).State = System.Data.Entity.EntityState.Modified;
                        db.SaveChanges();
                    }
                    return(Redirect("~/Tiendas/"));
                }
                return(View(model));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        public ActionResult NuevoP(ProductosViewModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    using (TredaEntities db = new TredaEntities())
                    {
                        var oTabla = new Productos();
                        oTabla.Nombre      = model.Nombre;
                        oTabla.Descripcion = model.Descripcion;
                        oTabla.Valor       = model.Valor;
                        oTabla.Tienda      = model.Tienda;
                        oTabla.Imagen      = model.Imagen;

                        db.Productos.Add(oTabla);
                        db.SaveChanges();
                    }
                    return(Redirect("~/Productos/"));
                }
                return(View(model));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        public ActionResult EliminarP(int ID)
        {
            ProductosViewModel model = new ProductosViewModel();

            using (TredaEntities db = new TredaEntities())
            {
                var oProducto = db.Productos.Find(ID);
                db.Productos.Remove(oProducto);
                db.SaveChanges();
            }
            return(Redirect("~/Productos/"));
        }
Ejemplo n.º 4
0
        public ActionResult EliminarT(int ID)
        {
            TiendasViewModel model = new TiendasViewModel();

            using (TredaEntities db = new TredaEntities())
            {
                var oTienda = db.Tiendas.Find(ID);
                db.Tiendas.Remove(oTienda);
                db.SaveChanges();
            }
            return(Redirect("~/Tiendas/"));
        }
Ejemplo n.º 5
0
        public ActionResult EditarT(TiendasViewModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    using (TredaEntities db = new TredaEntities())
                    {
                        var oTabla = db.Tiendas.Find(model.ID);
                        oTabla.Nombre            = model.Nombre;
                        oTabla.Fecha_de_Apertura = model.Fecha_de_Apertura;

                        db.Entry(oTabla).State = System.Data.Entity.EntityState.Modified;
                        db.SaveChanges();
                    }
                    return(Redirect("~/Tiendas/"));
                }
                return(View(model));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Ejemplo n.º 6
0
        public ActionResult NuevaT(TiendasViewModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    using (TredaEntities db = new TredaEntities())
                    {
                        var oTabla = new Tiendas();
                        oTabla.Nombre            = model.Nombre;
                        oTabla.Fecha_de_Apertura = model.Fecha_de_Apertura;

                        db.Tiendas.Add(oTabla);
                        db.SaveChanges();
                    }
                    return(Redirect("~/Tiendas/"));
                }
                return(View(model));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }