Exemplo n.º 1
0
        public async Task <IActionResult> GetClassesByDisciplineIDsTaskAsync([FromServices] IDisciplineBusiness disciplineBusiness, [FromServices] IStudentBusiness studentBusiness)
        {
            var studentId = Guid.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value);

            if (!(await studentBusiness.FindByStudentIdTaskAsync(studentId) is StudentDisciplineVO student))
            {
                return(NotFound("Não existe nenhum aluno com Id fornecido!"));
            }

            if (!(await disciplineBusiness.FindAllByDisciplineIdsTaskAsync(student.Disciplines.Select(x => x.DisciplineId).ToList()) is List <DisciplineVO> disciplines))
            {
                return(NotFound("Não foi possivel encontrar as disciplinas do aluno!"));
            }

            if (!(await _classBusiness.FindByRangeClassIdTaskAsync(disciplines.Select(x => x.ClassId).ToHashSet()) is List <ClassVO> classes))
            {
                return(NotFound("Não foi possivel encontrar as salsas do aluno"));
            }

            return(Ok(classes));
        }