Skip to content

Commit

Permalink
🔨 APP #270 melhorando regra
Browse files Browse the repository at this point in the history
  • Loading branch information
bjverde committed Sep 27, 2022
1 parent ce7d877 commit 218332b
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion appexemplo_v2.0/controllers/Acesso_perfil.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,23 @@ public function selectAll( $orderBy=null, $where=null )
return $result;
}
//--------------------------------------------------------------------------------
public function validarNomePerfilJaExiste( Acesso_perfilVO $objVo )
{
$where=array('NOM_PERFIL'=>$objVo->getNom_perfil());
$qtd = $this->selectCount($where);
if($qtd >= 1){
throw new DomainException('Já existe um perfil com o mesmo nome!');
}
}
public function validar( Acesso_perfilVO $objVo )
{
$this->validarNomePerfilJaExiste($objVo);
}
//--------------------------------------------------------------------------------
public function save( Acesso_perfilVO $objVo )
{
$result = null;
$this->validar();
if( $objVo->getIdperfil() ) {
$result = $this->dao->update( $objVo );
} else {
Expand All @@ -74,6 +88,5 @@ public function getVoById( $id )
$result = $this->dao->getVoById( $id );
return $result;
}

}
?>

0 comments on commit 218332b

Please sign in to comment.