Ejemplo n.º 1
0
        // GET: Clinicas
        public ActionResult Index()
        {
            var clinicas = _servicoClinica.ObterTodas();
            var model    = ObterModeloClinicas(clinicas);

            return(View(model));
        }
        private void PreencherDadosViewBag(int statusId = 0, int clinicaId = 0, object valorPadraoSelecionado = null)
        {
            var clinicas = clinicaId == 0
                ? _servicoClinica.ObterTodas()
                : new List<Clinica> { _servicoClinica.ObterPor(clinicaId) };

            ViewBag.ClinicaId = new SelectList(clinicas, nameof(Clinica.Id), nameof(Clinica.Nome));
            var status = statusId == 0
                ? _servicoDeAgendamento.ObterTodosOsStatusAgendamento()
                : _servicoDeAgendamento.ObterTodosOsStatusAgendamento()
                .Where(c => Convert.ToInt32(c.ID) == statusId);

            var listaStatus = status.Select(c => new SelectListItem
            {
                Text = c.Description,
                Value = ((int)c.ID).ToString(),
                Selected = valorPadraoSelecionado != null && ((int)c.ID).ToString().Equals(valorPadraoSelecionado.ToString())
            });
            ViewBag.StatusId = new SelectList(listaStatus, "Value", "Text");
        }