Exemplo n.º 1
0
        public async Task MatricularAsync(Guid alunoId, Guid pessoaFisicaId, Guid responsavelId, Guid escolaId, Guid salaId)
        {
            var pessoaFisica = await _pessoaFisicaRepository.GetByEntityIdAsync(pessoaFisicaId);

            if (pessoaFisica == null)
            {
                throw new PessoaFisicaNaoEncontradaException();
            }

            var responsavel = await _pessoaFisicaRepository.GetByEntityIdAsync(responsavelId);

            if (responsavel == null)
            {
                throw new ResponsavelNaoEncontradoException();
            }

            var escola = await _escolaRepository.GetByEntityIdAsync(escolaId);

            if (escola == null)
            {
                throw new EscolaNaoEncontradaException();
            }

            var matricula = await _matriculaService.GerarMatriculaAsync();

            var aluno = new Aluno(alunoId, pessoaFisica, responsavel, matricula);

            escola.AdicionarAluno(salaId, aluno);

            await _alunoRepository.AddAsync(aluno);
        }
Exemplo n.º 2
0
        public async Task <AlunoEditModelReturn> AddAlunoAsync(AlunoEditModel model)
        {
            var aluno = new Aluno();

            mapper.Map(model, aluno);
            await alunoRepository.AddAsync(aluno);

            await context.SaveChangesAsync();

            return(mapper.Map(aluno, new AlunoEditModelReturn()));
        }