// GET: /<controller>/
        public async Task <IActionResult> Index()
        {
            Professor professor;
            var       usuarioAtual = await _userManager.GetUserAsync(User);

            if (usuarioAtual.TipoUsuario != 2)
            {
                return(RedirectToAction("Index", "Perfil"));
            }
            professor = await _professorService.GetProfessorPorCPFAsync(usuarioAtual.UserName);

            IEnumerable <Turma_Aluno> alunos = await _turmaAlunoService.GetAlunosPorProfessorAsync(professor.Id);

            return(View(new ConsultarAlunoTurmaViewModel {
                Alunos = alunos.ToList()
            }));
        }
Пример #2
0
        public async Task <IActionResult> CadastrarAlunoTurma(string msgSucesso = null, string msgError = null)
        {
            var usuarioAtual = await _userManager.GetUserAsync(User);

            Professor professor = await _professorService.GetProfessorPorCPFAsync(usuarioAtual.UserName);

            IEnumerable <Turma> turmas = await _turmaService.GetTurmasPorProfessorAsync(professor.Id);

            IEnumerable <Turma_Aluno> turma_Alunos = await _turma_AlunoService.GetAlunosPorProfessorAsync(professor.Id);

            foreach (var item in turma_Alunos)
            {
                item.Aluno = await _alunoService.GetAlunoPorIdAlunoAsync(item.IdAluno);
            }
            CadastrarAlunoTurmaViewModel cadastrarAlunoTurmaViewModel = new CadastrarAlunoTurmaViewModel
            {
                Turma_Alunos = turma_Alunos
            };

            return(View(cadastrarAlunoTurmaViewModel));
        }