Пример #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))));
        }