Esempio n. 1
0
        private static Cliente InserindoNovoCliente(ClienteDados clienteDados)
        {
            Cliente cliente = new Cliente()
            {
                DataNascimento = DateTime.Parse("04/05/1982"),
                Nome           = "Cliente Teste",
                Sobrenome      = "Teste",
                Enderecos      = new System.Collections.Generic.List <Endereco>()
                {
                    new Endereco {
                        Logradouro = "a", Bairro = "b", Cidade = "c", Estado = "e", Cep = "18135070", Tipo = TipoEndereco.Residencial
                    },
                    new Endereco {
                        Logradouro = "f", Bairro = "g", Cidade = "h", Estado = "i", Cep = "18135070", Tipo = TipoEndereco.Comercial
                    }
                }
            };

            EnderecoDados enderecoDados = new EnderecoDados();

            cliente.Id = clienteDados.Insert(cliente);
            cliente.Enderecos.ForEach(endereco => {
                endereco.IdCliente = cliente.Id;
                endereco.Id        = enderecoDados.Insert(endereco);
            });

            return(cliente);
        }
Esempio n. 2
0
        //public void ValidaCliente(Cliente cliente)
        //{
        //    if (cliente.Cl_nome.Length > 3 || (!Regex.IsMatch(cliente.Cl_nome, caracteres)))
        //    {
        //        throw new CampoVazioException("Numero de caracteres inferior ou dados do Nome inválidos, favor tente novamente");
        //    }
        //    if (cliente.Cl_celular.Length < 11 || cliente.Cl_telefone.Length < 10 || cliente.Cl_telefone2.Length < 10)
        //    {
        //        throw new CampoVazioException("Numero de Celular ou Telefone inválidos, favor tente novamente");
        //    }
        //    if (cliente.Cl_rg.Length < 5 || (!Regex.IsMatch(cliente.Cl_rg, numeros)))
        //    {
        //        throw new CampoVazioException("Campo RG Invalido, favor tente novamente");
        //    }
        //    if (cliente.Cl_cep.Length < 8)
        //    {
        //        throw new CampoVazioException("Campo CEP Invalido, favor tente novamente");
        //    }
        //    if (cliente.Cl_endereco.Length < 7 || (!Regex.IsMatch(cliente.Cl_endereco, LetraseNum)))
        //    {
        //        throw new CampoVazioException("Campo Endereço Invalido, favor tente novamente");
        //    }
        //    if (cliente.Cl_numero.Length > 5 || cliente.Cl_numero.Equals("0") || (!Regex.IsMatch(cliente.Cl_numero, numeros)))
        //    {
        //        throw new CampoVazioException("Campo Numero Invalido, favor tente novamente");
        //    }
        //    if (cliente.Cl_bairro.Length < 4 || (!Regex.IsMatch(cliente.Cl_bairro, CidadeseBairros)))
        //    {
        //        throw new CampoVazioException("Campo Bairro Invalido, favor tente novamente");
        //    }
        //    if (cliente.Cl_cidade.Length < 4 || (!Regex.IsMatch(cliente.Cl_cidade, CidadeseBairros)))
        //    {
        //        throw new CampoVazioException("Campo Cidade Invalido, favor tente novamente");
        //    }
        //    if (cliente.Cl_uf.Length >= 2 )
        //    {
        //        throw new CampoVazioException("Campo UF Invalido, favor tente novamente");
        //    }
        //    if (cliente.Cl_nomepai.Length < 3 || (!Regex.IsMatch(cliente.Cl_nomepai, caracteres)))
        //    {
        //        throw new CampoVazioException("Campo Pai Invalido, favor tente novamente");
        //    }
        //    if (cliente.Cl_nomemae.Length < 3 || (!Regex.IsMatch(cliente.Cl_nomemae, caracteres)))
        //    {
        //        throw new CampoVazioException("Campo Mãe Invalido, favor tente novamente");
        //    }
        //    if (cliente.Cl_profissao.Length < 5 || (!Regex.IsMatch(cliente.Cl_profissao, caracteres)))
        //    {
        //        throw new CampoVazioException("Campo Profissão Invalido, favor tente novamente");
        //    }
        //    if (cliente.Cl_observacoes.Length < 5 || (!Regex.IsMatch(cliente.Cl_profissao, LetraseNum)))
        //    {
        //        throw new CampoVazioException("Campo Observação Invalido, favor tente novamente");
        //    }
        //    if (!Regex.IsMatch(cliente.Cl_email, modelo_Email))
        //    {
        //        throw new CampoVazioException("Campo Email Invalido, favor tente novamente");
        //    }

        //}



        public void Insert(Cliente cliente)
        {
            cl.Insert(cliente);
        }