Beispiel #1
0
        public async Task <int> IncluirAlunoAsync(int turmaId, string nomeAluno)
        {
            var aluno = new Aluno()
            {
                Nome = nomeAluno, TurmaId = turmaId
            };

            var erros = aluno.Validate();

            if (erros.Length == 0)
            {
                await _alunoRepository.AdicionarAsync(aluno);

                _alunoRepository.SaveChanges();

                return(aluno.Id);
            }
            else
            {
                throw new DomainException(erros);
            }
        }