public function save(SampleModel &$model)
 {
     if ($id = $model->getAttribute('id')) {
         if (null === ($record = $this->record->findByPk($id))) {
             throw new Exception(Craft::t('Can\'t find a sample with ID "{id}"', array('id' => $id)));
         }
     } else {
         $record = new SampleRecord();
     }
     $record->setAttributes($model->getAttributes());
     if ($record->save()) {
         // update id on model (for new records)
         $model->setAttribute('id', $record->getAttribute('id'));
         return true;
     } else {
         $model->addErrors($record->getErrors());
         return false;
     }
 }