Exemple #1
0
        public async Task <StudentDisciplineVO> AddTaskAsync(StudentVO student)
        {
            StudentModel studentEntity = _studentConverter.Parse(student);

            if (!(GuidFormat.TryParseList(studentEntity.Disciplines, ';', out List <Guid> result)))
            {
                return(null);
            }

            //checando se não existe nenhuma disciplina repetida.
            foreach (Guid disc in result)
            {
                if (result.Count(x => x.Equals(disc)) > 1)
                {
                    return(null);
                }
            }

            if (!(await _disciplineBusiness.FindAllByDisciplineIdsTaskAsync(result) is List <DisciplineVO> disciplines))
            {
                return(null);
            }

            if (!(await _studentRepository.AddTaskAsync(studentEntity) is StudentModel addedStudent))
            {
                return(null);
            }

            //await _emailSender.SendEmailTaskAsync(addedStudent.Email);

            return(_studentDisciplineConverter.Parse((addedStudent, _disciplineConverter.ParseList(disciplines))));
        }
        public async Task <IActionResult> GetDisciplinesTaskAsync([FromBody] List <Guid> disciplines)
        {
            if (ModelState.IsValid)
            {
                if (await _disciplineBusiness.FindAllByDisciplineIdsTaskAsync(disciplines) is List <DisciplineVO> discs)
                {
                    return(Ok(discs));
                }

                return(NotFound("Uma ou todas as disciplinas requisitadas não foram localizadas!"));
            }

            return(BadRequest());
        }
Exemple #3
0
        public async Task <List <LessonDisciplineVO> > FindFiveLastLessonsByCourseIdTaskAsync(Guid courseId)
        {
            if (!(await _lessonRepository.FindFiveLastLessonsByCourseIdTaskAsync(courseId) is List <LessonModel> listLessons))
            {
                return(null);
            }

            if (!(await _disciplineBusiness.FindAllByDisciplineIdsTaskAsync(listLessons.Select(x => x.DisciplineId).ToHashSet().ToList()) is List <DisciplineVO> listDisciplines))
            {
                return(null);
            }

            List <DisciplineModel> disciplineModels = _disciplineConverter.ParseList(listDisciplines);

            var lessonDisciplines = new List <(LessonModel, DisciplineModel)>();

            foreach (LessonModel l in listLessons)
            {
                lessonDisciplines.Add((l, disciplineModels.Where(x => x.DisciplineId == l.DisciplineId).SingleOrDefault()));
            }

            return(_lessonDisciplineConverter.ParseList(lessonDisciplines));
        }
        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));
        }