Esempio n. 1
0
        public void Create(string nome, string CPF, DateTime dtNascimento)
        {
            if (this.Repository.GetByCPF(CPF) != null)
            {
                throw new Exception($"Cliente já existe na base com este cpf {CPF}");
            }

            //FACTORY
            var cliente = ClienteFactory.Criar(nome, CPF, dtNascimento);

            //BUILDER
            //var cliente = new ClienteBuilder()
            //	.Criar(nome, CPF, dtNascimento)
            //	.AdicionarPassword("abdc#1234")
            //	.AdicionarEndereco(new Domain.Cliente.Aggregate.Entity.Endereco())
            //	.AdicionarTelefone(
            //		new Domain.Cliente.Aggregate.Entity.Telefone()
            //		{
            //			Numero = new Domain.Cliente.Aggregate.ValueObject.NumeroTelefone("99999-8888"),
            //			Tipo = Domain.Cliente.Aggregate.Enum.Tipo.Comercial
            //		})
            //	.Build();

            this.Repository.Save(cliente);
        }
 public void Testar_Cliente_Com_Factory()
 {
     //eu programador nao preciso saber como inicializa
     //a classe e configurar a classe
     //ja recebeo ela previamente
     //inicializada e configurada
     var cliente = ClienteFactory.Criar(1);
 }
Esempio n. 3
0
        public void Create(string nome, string CPF, DateTime dtNascimento)
        {
            if (this.Repository.GetByCpf(CPF) != null)
            {
                throw new Exception($"Cliente já existente na base com este cpf {CPF}");
            }

            var cliente = ClienteFactory.Criar(nome, CPF, dtNascimento);

            this.Repository.Save(cliente);
        }