Exemple #1
0
        public Task HandleAsync(IDomainEvent <ExamAggregate, ExamId, ScoringStarted> domainEvent, ISagaContext sagaContext, CancellationToken cancellationToken)
        {
            foreach (var answer in domainEvent.AggregateEvent.StudentAnswers)
            {
                //if something blows up somehow somewhere we got a duplicate answer per question
                var question = domainEvent.AggregateEvent.Questions.Single(_ => _.Id == answer.Id);
                QuestionsAndStudentAnswers.TryAdd(question, answer);
            }

            Emit(new ExamScoringSagaStarted());
            return(Task.CompletedTask);
        }
Exemple #2
0
 private void CheckIfExamScoringIsCompleted(ScoreReceived aggregateEvent)
 {
     AllQuestionsScored = QuestionsAndStudentAnswers
                          .All(questionsAndStudentAnswer =>
                               questionsAndStudentAnswer.Key.Id == aggregateEvent.Score.QuestionId);
 }