OEModule\PASAPI\resources\PatientAppointment::save PHP Method

save() public method

public save ( )
    public function save()
    {
        $assignment = $this->getAssignment();
        $model = $assignment->getInternal(true);
        // track whether we are creating or updating
        $this->isNewResource = $model->isNewRecord;
        if ($this->isNewResource && $this->partial_record) {
            $this->addError('Cannot perform partial update on a new record');
            return;
        }
        if (!$this->validate()) {
            return;
        }
        $transaction = $this->startTransaction();
        try {
            if ($model = $this->saveModel($model)) {
                $assignment->internal_id = $model->id;
                $assignment->save();
                $assignment->unlock();
                $this->audit($this->isNewResource ? 'create' : 'update', null, null, null);
                if ($transaction) {
                    $transaction->commit();
                }
                return $model->id;
            }
        } catch (\Exception $e) {
            if ($transaction) {
                $transaction->rollback();
            }
            throw $e;
        }
    }