/**
  * @param ProductBindingModel $product
  * @throws \Exception
  * @Route("list")
  */
 public function listNewProduct(ProductBindingModel $product)
 {
     if ($_POST['csrf'] !== $_SESSION["token"]) {
         http_response_code(400);
         ob_end_clean();
         echo "CSRF not matching error";
         die;
     }
     if (!$product->modelState()->isValid()) {
         http_response_code(400);
         ob_end_clean();
         var_dump($product->modelState()->get());
         die;
     }
     $this->_productsRepo->create($product);
 }
 public function create(ProductBindingModel $product)
 {
     // Insert or update the $product
     // in the 'products' table
     $this->db->insertEntity('products', array('name' => $product->getName(), 'quantity' => $product->getQuantity(), 'category_id' => $product->getCategoryId(), 'description' => $product->getDescription(), 'price' => $product->getPrice(), 'date_listed' => $product->getDateListed(), 'is_deleted' => $product->getIsDeleted()));
 }