Example #1
0
        // GET: Aluno
        public ActionResult Index(AlunoSearchModel searchModel)
        {
            var viewModel = this.AlunoService.GetAssociationViewModel(searchModel);

            ViewBag.Escolas = EscolaRepository.GetAll().ToList();
            if (searchModel.TurmaId.HasValue)
            {
                viewModel.SearchModel.EscolaId = TurmaRepository.GetById(searchModel.TurmaId.Value).EscolaId;
            }
            if (viewModel.SearchModel.EscolaId.HasValue)
            {
                ViewBag.Turmas = TurmaRepository.GetByEscolaIds(new int[] { viewModel.SearchModel.EscolaId.Value }).ToList();
            }
            else
            {
                ViewBag.Turmas = Enumerable.Empty <SelectListItem>();
            }

            return(View(viewModel));
        }