Esempio n. 1
0
 if (array_key_exists("time", $_POST)) {
     $recipe->settime($_POST['time']);
 }
 if (array_key_exists("calories", $_POST)) {
     $recipe->setcalories($_POST['calories']);
 }
 if (array_key_exists("countryId", $_POST)) {
     $origin = $_POST["countryId"];
     if ($origin != "-1") {
         $recipe->setorigin($origin);
     }
 }
 if (array_key_exists("categoryId", $_POST)) {
     $category = $_POST["categoryId"];
     if ($category != "-1") {
         $recipe->setcategory($category);
     }
 }
 if (array_key_exists("tags", $_POST)) {
     $tags = TagService::processTags($_POST["tags"]);
     foreach ($tags as $current) {
         $newTag = new tags();
         $newTag->settagNames($current);
         $recipe->addtags($newTag);
     }
 }
 $saved = ItemService::saveWithValidation($recipe, 200);
 if ($saved == true) {
     $id = $recipe->getId();
     $result = array("id" => $id);
     echo json_encode($result);