Beispiel #1
0
        public async Task HandleAsync(CreateSubmission command)
        {
            var speakersIds = command.SpeakersIds.Select(x => new AggregateId(x));
            var speakers    = await _speakerRepository.BrowserAsync(speakersIds);

            if (speakers.Count() != speakersIds.Count())
            {
                throw new InvalidSpeakerNumberException(command.Id);
            }

            var submission = Submission.Create(command.Id, command.ConferenceId, command.Title, command.Description,
                                               command.Level, command.Tags, speakers.ToList());

            await _submissionRepository.AddAsync(submission);

            var events = _eventMapper.MapAll(submission.Events);
            await _messageBroker.PublishAsync(events.ToArray());

            await _domainEventDispatcher.DispatchAsync(submission.Events.ToArray());
        }