public static bool ReponerProducto(int Id, int cant) { bool paso = false; Contexto db = new Contexto(); Productos p = ProductosBLL.Buscar(Id); if (p != null) { p.Cantidad += cant; db.Entry(p).State = EntityState.Modified; paso = (db.SaveChanges() > 0); } return(paso); }
public static bool QuitarProducto(int Id, int cant) { bool paso = false; Contexto db = new Contexto(); Productos p = ProductosBLL.Buscar(Id); if (p != null) { if (p.Cantidad < 1 || cant > p.Cantidad) { return(paso); } else { p.Cantidad -= cant; db.Entry(p).State = EntityState.Modified; paso = (db.SaveChanges() > 0); } } return(paso); }