Esempio n. 1
0
             $product = new Product($productId, $requestObject->vendorId, $requestObject->description, $requestObject->leadTime, $requestObject->sku, $requestObject->title);
             $product->update($pdo);
             $reply->data = "Product updated OK";
             // delete an existing Product
         } else {
             if ($method === "DELETE") {
                 verifyXsrf();
                 $productAlerts = ProductAlert::getProductAlertByProductId($pdo, $productId);
                 foreach ($productAlerts as $productAlert) {
                     $productAlert->delete($pdo);
                 }
                 $finishedProducts = FinishedProduct::getFinishedProductByRawMaterialId($pdo, $productId);
                 foreach ($finishedProducts as $finishedProduct) {
                     $finishedProduct->delete($pdo);
                 }
                 $productLocations = ProductLocation::getProductLocationByProductId($pdo, $productId);
                 foreach ($productLocations as $productLocation) {
                     $productLocation->delete($pdo);
                 }
                 $movements = Movement::getMovementByProductId($pdo, $productId);
                 foreach ($movements as $movement) {
                     $movement->delete($pdo);
                 }
                 $product = Product::getProductByProductId($pdo, $productId);
                 $product->delete($pdo);
                 $reply->data = "Product deleted OK";
             }
         }
     }
 }
 // create an exception to pass back to the RESTful caller
 /**
  * test grabbing a ProductLocation by productId that does not exist
  **/
 public function testGetInvalidProductLocationByProductId()
 {
     // grab an productId that does not exist
     $pdoProductLocation = ProductLocation::getProductLocationByProductId($this->getPDO(), InventoryTextTest::INVALID_KEY);
     foreach ($pdoProductLocation as $pdoPL) {
         $this->assertNull($pdoPL);
     }
 }