Exemplo n.º 1
0
        public bool AdicionarProfessor(TurmaProfessorDTO turmaProfessor)
        {
            var transaction = this.turmaProfessorRepository.GetTransaction();

            try
            {
                var turma = this.turmaRepository.GetById(turmaProfessor.TurmaId);
                if (turma.TurmasProfessor.Any(x => x.ProfessorId == turmaProfessor.Professor.Id))
                {
                    throw new BusinessException("O professor já está vinculado na turma.");
                }
                var tp = turmaProfessor.ToEntity();
                turmaProfessorRepository.Add(tp);
                turmaProfessorRepository.SaveChanges();
                transaction.Commit();
                return(true);
            }
            catch
            {
                transaction.Rollback();
                throw;
            }
            finally
            {
                transaction.Dispose();
            }
        }
Exemplo n.º 2
0
 public bool AdicionarProfessor(TurmaProfessorDTO turmaProfessor)
 {
     return(TurmaService.AdicionarProfessor(turmaProfessor));
 }