public void Subscribe(User user, Course course, SendQuestionManager sendQuestionManager, QuestionManager _questionManager) { if (user.IsTeacher) { throw new QuestionarException("Apenas alunos podem se cadastrar em disciplinas."); } if (!user.Active) { throw new QuestionarException("Usuários inativos não podem se cadastrar."); } if (Repository.Query().Any(c => c.Student.Id == user.Id && c.Course.Id == course.Id)) { throw new QuestionarException("Usuário já inscrito nesta disciplina."); } Transaction(() => { var subscription = new Subscription { Course = course, Entered = DateTime.Now, Student = user }; Repository.Create(subscription); sendQuestionManager.SendQuestion(user, course, _questionManager); }); }
public void SendFirstQuestion(SubscribeManager subscribeManager, SendQuestionManager sendQuestionManager, Course course, Question question) { var users = subscribeManager.UsersByCourse(course); users.ForEach(user => { sendQuestionManager.SendQuestion(user, course, question); }); }