/**
  * Request handler to implement in child classes.
  *
  * @return JsonResponse
  */
 protected function run()
 {
     $storage = AddProductController::getStorageArr();
     foreach ($this->request->request as $prod_id => $discountData) {
         $storage[$prod_id]['discounts'][] = ["threshold" => $discountData['threshold'], "amount" => $discountData['amount'], "type" => $discountData['type'], "creationDate" => date("Y-m-d H:i:s"), "expiryDate" => null];
     }
     AddProductController::saveStorageArr($storage);
     return $this->app->json(["status" => "OK"]);
 }
 /**
  * Request handler to implement in child classes.
  *
  * @return JsonResponse
  */
 protected function run()
 {
     $products = AddProductController::getStorageArr();
     $prodId = $this->request->request->get("prodId");
     $creationDate = $this->request->request->get("creationDate");
     foreach ($products as $id => &$prod) {
         if ($id === $prodId) {
             foreach ($prod['discounts'] as &$d) {
                 if ($d['creationDate'] === $creationDate) {
                     $d['expiryDate'] = date("Y-m-d H:i:s");
                 }
             }
         }
     }
     AddProductController::saveStorageArr($products);
     return $this->app->json(["status" => "OK"]);
 }