Exemple #1
0
        static void Main(string[] args)
        {
            bool aux;

            Console.WriteLine("Gerir Pessoas");
            PessoaSemLista p1 = new PessoaSemLista("Um Nome");
            //Pessoas.Add(p1);  //evitar aceder diretamente aos dados!!!

            A a = new A();


            try
            {
                aux = Regras.InserePessoaA(p1, a);

                //aux = Regras.InsereA(p1.nome, a);
                //Regras.InserePessoa(p1, 3);

                if (aux == true)
                {
                    Console.WriteLine("Inserido: Nome: " + p1.nome);
                }
                else
                {
                    Console.WriteLine("Não foi Inserido: Nome: " + p1.nome);
                }
            }
            catch (InsercaoException e)
            {
                Console.WriteLine(e.Message);
            }

            Console.ReadKey();
        }
Exemple #2
0
 /// <summary>
 /// Insere nova pessoa
 /// Devolve Exceção "InsereException"
 /// </summary>
 /// <param name="p"></param>
 /// <param name="perfil"></param>
 /// <returns></returns>
 public static bool InserePessoa(PessoaSemLista p, int perfil)
 {
     //Aplicar regra de negócio
     if (perfil > 0)
     {
         try
         {
             return(Pessoas.AddPessoa(p));
         }
         catch (InsercaoException e)
         {
             throw e;
         }
     }
     return(false);
 }
Exemple #3
0
        public static bool AddPessoa(PessoaSemLista p, A a)
        {
            try
            {
                //PessoaSemLista em Pessoa;
                Pessoa aux = new Pessoa(a);
                aux.nome = p.nome;

                if (todasPessoas.Contains(aux))
                {
                    return(false);                              //Rever Contains que percorre pelo "nome"
                }
                todasPessoas.Add(aux);
            }
            catch (InsercaoException e)
            {
                throw e;
            }
            return(true);
        }
Exemple #4
0
 public static bool InserePessoaA(PessoaSemLista p, A a)
 {
     return(Pessoas.AddPessoa(p, a));
 }