예제 #1
0
        // GET: api/Pessoa
        public IEnumerable <Pessoa> Get()
        {
            var pessoa = PessoaDB.Get();

            // Retorna o número de anos
            pessoa.ForEach(p => {
                int YearsAge = DateTime.Now.Year - p.Nasc.Year;
                // Se a data de aniversário não ocorreu ainda este ano, subtrair um ano a partir da idade
                if (DateTime.Now.Month < p.Nasc.Month || (DateTime.Now.Month == p.Nasc.Month && DateTime.Now.Day < p.Nasc.Day))
                {
                    p.Idade = YearsAge--;
                }
                p.Idade = YearsAge;
            });
            return(pessoa);
        }
예제 #2
0
        //
        // GET: /Pessoa/Delete/5

        public ActionResult Excluir(int id)
        {
            return(View(PessoaDB.Get(id)));
        }
예제 #3
0
        //
        // GET: /Pessoa/Details/5

        public ActionResult Detalhes(int id)
        {
            return(View(PessoaDB.Get(id)));
        }
예제 #4
0
        //
        // GET: /Pessoa/

        public ActionResult Index()
        {
            return(View(PessoaDB.Get()));
        }