public void HandleEvent(IEvent @event)
        {
            Console.WriteLine($"registered {@event.GetType()}");
            switch (@event)
            {
            case QuizWasCreatedEvent e:
                _createdQuizzes.Add(e.QuizId, 0);
                break;

            case QuizWasPublished e:
                _createdQuizzes.Remove(e.QuizId);
                break;

            case DayWasPassedEvent e:
                if (++_createdQuizzes[e.QuizId] > 2)
                {
                    _quizUseCases.HandleCommand(new CancelQuizCreationCommand()
                    {
                        QuizId = e.QuizId
                    });
                }
                break;

            default:
                break;
            }
        }
예제 #2
0
        public void HandleEvent(IEvent @event)
        {
            Console.WriteLine($"registered {@event.GetType()}");
            switch (@event)
            {
            case QuizWasCreatedEvent e:
                _quizUseCases.HandleCommand(new Commands.ReserveQuizNameCommand()
                {
                    Name = e.QuizName, QuizId = e.QuizId
                });
                break;

            case QuizNameReservedEvent e:
                _quizUseCases.HandleCommand(new Commands.ApproveQuizNameCommand()
                {
                    QuizId = e.QuizId
                });
                break;

            default:
                break;
            }
        }
예제 #3
0
 public void When(CancelQuizCreationCommand command)
 {
     _quizUseCases.HandleCommand(command);
 }