예제 #1
0
function libCorpSaveEndereco($endereco, $userCredential = NULL)
{
    $xmlResult = '<result><status>%s</status><errocode>%s</errocode><response>%s</response></result>';
    try {
        Registry::factory()->setCredential($userCredential);
        $voEndereco = EnderecoValueObject::factory()->loadData($endereco);
        $voEndereco = EnderecoBusiness::factory()->save($voEndereco);
        return sprintf($xmlResult, 'success', '000000', $voEndereco->toXml());
    } catch (\Exception $excp) {
        return sprintf($xmlResult, 'failure', $excp->getCode(), $excp->getMessage());
    }
}
예제 #2
0
 /**
  * Atualiza os dados de Endereco
  *
  * @example EnderecoBusiness::updateEndereco
  * @code
  * <?php
  *     # cria filtro usado por agencia
  *     $voEndereco       = ValueObjectAbstract::factory('fullnamespace');
  *     # outra forma de utilizar
  *     # $voEndereco = EnderecoValueObject::factory();
  *     $voEndereco->setSqEndereco(1);
  *
  *     # efetua atualizacao
  *     $enderecoBusiness = DocumentoBusiness::factory();
  *     $enderecoBusiness->updateEndereco($voEndereco);
  * ?>
  * @endcode
  *
  * @param EnderecoValueObject $voEndereco
  * @return EnderecoValueObject
  * @throws BusinessException
  */
 public function updateEndereco(EnderecoValueObject $voEndereco)
 {
     try {
         $voEnderecoTmp = EnderecoBusiness::factory(NULL, 'libcorp')->find($voEndereco->getSqEndereco());
         $voEnderecoTmp->loadData($this->keepUpdateData($voEndereco));
         if (NULL == $voEndereco->getNuEndereco()) {
             $voEndereco->setNuEndereco(NULL);
         }
         if (NULL == $voEndereco->getTxComplemento()) {
             $voEndereco->setTxComplemento(NULL);
         }
         $this->getModelPersist('libcorp')->update($voEnderecoTmp);
         return $voEnderecoTmp;
     } catch (ModelException $mExcp) {
         throw new BusinessException($mExcp->getMessage(), $mExcp->getCode());
     }
 }