Beispiel #1
0
        IEnumerable <PessoasDTOList> IPessoaRepositorio.ListarTodos()
        {
            PessoasDTOList        lPessoa      = new PessoasDTOList();
            List <PessoasDTOList> lListPessoas = new List <PessoasDTOList>();
            var pessoas = dao.ListarTodos();

            foreach (var p in pessoas)
            {
                lPessoa.codPessoa   = p.id.ToString();
                lPessoa.nomePessoa  = p.nome;
                lPessoa.emailPessoa = p.email;
                lPessoa.cpfPessoa   = p.cpf;
                var hoje = DateTime.Today;

                // calculo da idade da pessoa
                var a = (hoje.Year * 100 + hoje.Month) * 100 + hoje.Day;
                var b = (p.dataNascimento.Year * 100 + p.dataNascimento.Month) * 100 + p.dataNascimento.Day;

                lPessoa.idadePessoa = ((a - b) / 10000).ToString();

                // traz o total de telefones
                //lPessoa.qtdTel = dao.TotalTelefones((int)p.id).ToString();
                lListPessoas.Add(lPessoa);
            }

            return(lListPessoas);
        }
Beispiel #2
0
 public ActionResult <IEnumerable <PessoaDto> > Get()
 {
     return(_pessoaDao.ListarTodos()
            .Select(p => new PessoaDto()
     {
         id = p.Id,
         nome = p.Nome,
         email = p.Email,
         cpf = p.CPF,
         dataNascimento = p.DataNascimento,
         telefones = p.Telefones.Select(t => new TelefoneDto()
         {
             id = t.Id,
             ddd = t.DDD,
             numero = t.Numero
         }).ToList()
     })
            .ToList());
 }