コード例 #1
0
        public async Task Handle(VotePosted notification, CancellationToken cancellationToken)
        {
            var answer = await _answersRepository.Get(notification.AnswerId) !;

            if (answer is null)
            {
                throw new NullReferenceException(
                          $"answer with id {notification.AnswerId} was not found");
            }

            answer.IncrementVotes();

            await _domainEvents
            .CollectFrom(answer)
            .PublishCollected(cancellationToken);
        }