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/")); }
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/")); }
public ActionResult EditarT(int ID) { TiendasViewModel model = new TiendasViewModel(); using (TredaEntities db = new TredaEntities()) { var oTienda = db.Tiendas.Find(ID); model.Nombre = oTienda.Nombre; model.Fecha_de_Apertura = oTienda.Fecha_de_Apertura; model.ID = oTienda.ID; } return(View(model)); }
public ActionResult EditarP(int ID) { ProductosViewModel model = new ProductosViewModel(); using (TredaEntities db = new TredaEntities()) { var oProducto = db.Productos.Find(ID); model.Nombre = oProducto.Nombre; model.Descripcion = oProducto.Descripcion; model.Valor = oProducto.Valor; model.Tienda = oProducto.Tienda; model.Imagen = oProducto.Imagen; model.SKU = oProducto.SKU; } return(View(model)); }
// GET: Tiendas public ActionResult Index() { List <ListTiendasViewModel> lst; using (TredaEntities db = new TredaEntities()) { lst = (from d in db.Tiendas select new ListTiendasViewModel { ID = d.ID, Nombre = d.Nombre, Fecha_de_Apertura = d.Fecha_de_Apertura }).ToList(); } return(View(lst)); }
// GET: Tiendas public ActionResult IndexP() { List <ListProductosViewModel> lst; using (TredaEntities db = new TredaEntities()) { lst = (from d in db.Productos select new ListProductosViewModel { SKU = d.SKU, Nombre = d.Nombre, Descripcion = d.Descripcion, Valor = d.Valor, Tienda = d.Tienda, Imagen = d.Imagen }).ToList(); } return(View(lst)); }
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); } }
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); } }