Exemple #1
0
        private List <SelectListItem> ObterPlanos()
        {
            List <SelectListItem> lista = new List <SelectListItem>();

            PlanoRepositorio rep = new PlanoRepositorio();

            foreach (Plano p in rep.FindAll())
            {
                SelectListItem item = new SelectListItem();
                item.Value = p.IdPlano.ToString();
                item.Text  = p.Nome;

                lista.Add(item);
            }
            return(lista);
        }
Exemple #2
0
        public ActionResult Consulta()
        {
            List <PlanoConsultaViewModel> lista = new List <PlanoConsultaViewModel>();

            try
            {
                PlanoRepositorio rep = new PlanoRepositorio();
                foreach (Plano p in rep.FindAll())
                {
                    PlanoConsultaViewModel model = new PlanoConsultaViewModel();
                    model.IdPlano   = p.IdPlano;
                    model.Nome      = p.Nome;
                    model.Descricao = p.Descricao;

                    lista.Add(model);
                }
            }
            catch (Exception e)
            {
                ViewBag.Mensagem = "Erro " + e.Message;
            }

            return(View(lista));
        }