/** * API Method inserts a new Transcription record and render response as JSON */ public function Create() { try { $json = json_decode(RequestUtil::GetBody()); if (!$json) { throw new Exception('The request body does not contain valid JSON'); } $transcription = new Transcription($this->Phreezer); // TODO: any fields that should not be inserted by the user should be commented out // this is an auto-increment. uncomment if updating is allowed // $transcription->Idtranscription = $this->SafeGetVal($json, 'idtranscription'); $transcription->Iditem = $this->SafeGetVal($json, 'iditem'); $transcription->Idmedia = $this->SafeGetVal($json, 'idmedia'); $transcription->Transcription = $this->SafeGetVal($json, 'transcription'); $transcription->Notes = $this->SafeGetVal($json, 'notes'); $transcription->Language = $this->SafeGetVal($json, 'language'); $transcription->Validate(); $errors = $transcription->GetValidationErrors(); if (count($errors) > 0) { $this->RenderErrorJSON('Please check the form for errors', $errors); } else { $transcription->Save(); $this->RenderJSON($transcription, $this->JSONPCallback(), true, $this->SimpleObjectParams()); } } catch (Exception $ex) { $this->RenderExceptionJSON($ex); } }