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(); } }
public bool AdicionarProfessor(TurmaProfessorDTO turmaProfessor) { return(TurmaService.AdicionarProfessor(turmaProfessor)); }