Package maissocial.controle

Source Code of maissocial.controle.UfControle

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package maissocial.controle;

import java.util.List;
import maissocial.entidade.Uf;
import maissocial.exception.UfJaCadastradaException;
import maissocial.repositorio.UfRepositorio;

/**
*
* @author luciano
*/
public class UfControle {

    private UfRepositorio ufRep;

    public UfControle(){
        this.ufRep = new UfRepositorio();
    }

    public void salvarUf(Uf uf) throws Exception, UfJaCadastradaException{
        if( uf == null || uf.getNome() == null || uf.getNome().equals("") || uf.getStatus() == 0){
            throw  new Exception("Parâmetros Inválidos!");
        }

        Uf uf2 = this.ufRep.pesquisarUfPorNome(uf.getNome());
        if(uf2 == null){
            this.ufRep.salvarUf(uf);
        }else{
            throw new UfJaCadastradaException("UF já cadastrado!");
        }

    }

    public void deletarUfPorObj(Uf uf){
        this.ufRep.deletarUfPorObj(uf);
    }

    public void deletarUf(int cod){
        this.ufRep.deletarUf(cod);
    }

    public void alterarUf(Uf uf) throws Exception, UfJaCadastradaException{
        if( uf == null || uf.getNome() == null || uf.getNome().equals("") || uf.getStatus() == 0){
            throw  new Exception("Parâmetros Inválidos!");
        }

        Uf uf2 = this.ufRep.pesquisarUfPorNome(uf.getNome());
        if(uf2 == null){
            this.ufRep.alterarUf(uf);
        }else{
            throw new UfJaCadastradaException("UF já cadastrado!");
        }
    }

    public Uf pesquisarUfPorCodigo(int cod){
        Uf uf = this.ufRep.pesquisarUfPorCodigo(cod);
        return uf;
    }

    public Uf pesquisarUfPorSigla(String sigla){
        Uf uf = this.ufRep.pesquisarUfPorSigla(sigla);
        return uf;
    }

     public Uf pesquisarUfPorNome(String nome){
        Uf uf = this.ufRep.pesquisarUfPorNome(nome);
        return uf;
    }

    public List pesquisarUfTodos(){
        List uf = this.ufRep.pesquisarUfTodos();
        return uf;
    }

}
TOP

Related Classes of maissocial.controle.UfControle

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.