} else {
            $id = $_POST['id'];
            $product = $this->map_data();
            $product->set_id($id);
            $this->productrepository->update($product);
            header("Location:index.php?page=admin&action=success");
        }
    }
    public function delete()
    {
        $id = $_GET['id'];
        $this->productrepository->delete($id);
        header("Location: index.php?page=admin&action=delete");
    }
}
$adminproductcontroller = new AdminProductController();
if (isset($_GET['m'])) {
    $method = $_GET['m'];
} else {
    $method = "index";
}
switch ($method) {
    case 'add':
        $adminproductcontroller->add();
        break;
    case 'edit':
        $adminproductcontroller->edit();
        break;
    case 'delete':
        $adminproductcontroller->delete();
        break;
            if ($result_edit > 0) {
                header('location:index.php?page=aproduct&update=true');
            } else {
                header('location:index.php?page=aproduct&update=false');
            }
        }
    }
    public function delete()
    {
        if (isset($_GET['id'])) {
            $this->product_repo->delete($_GET['id']);
            header('location:index.php?page=aproduct');
        }
    }
}
$product = new AdminProductController();
$method = isset($_GET['m']) ? $_GET['m'] : '';
switch ($method) {
    case 'add':
        $product->add();
        break;
    case 'edit':
        $product->edit();
        break;
    case 'delete':
        $product->delete();
        break;
    default:
        $product->index();
        break;
}