public async Task HandleAsync(CreateSubmission command) { var callForPapers = await _callForPapersRepository.GetAsync(command.ConferenceId); if (callForPapers is null) { throw new CallForPapersNotFoundException(command.ConferenceId); } if (!callForPapers.IsOpened) { throw new CallForPapersClosedException(command.ConferenceId); } var speakerIds = command.SpeakerIds.Select(id => new AggregateId(id)); var speakers = await _speakerRepository.BrowseAsync(speakerIds); if (speakers.Count() != command.SpeakerIds.Count()) { throw new MissingSubmissionSpeakersException(command.Id); } var submission = Submission.Create(command.Id, command.ConferenceId, command.Title, command.Description, command.Level, command.Tags, speakers); await _submissionRepository.AddAsync(submission); await _dispatcher.DispatchAsync(submission.Events.ToArray()); var integrationEvents = _eventMapper.MapAll(submission.Events); await _messageBroker.PublishAsync(integrationEvents.ToArray()); }
public async Task HandleAsync(CreateSubmission command) { var callForPapers = await _callForPapersRepository.GetAsync(command.ConferenceId); if (callForPapers is null) { throw new CallForPapersNotFoundException(command.ConferenceId); } if (!callForPapers.IsOpened) { throw new CallForPapersClosedException(command.ConferenceId); } var speakerIds = command.SpeakerIds.Select(id => new AggregateId(id)); var speakers = await _speakerRepository.BrowseAsync(speakerIds); if (speakers.Count() != command.SpeakerIds.Count()) { throw new MissingSubmissionSpeakersException(command.Id); } var submission = Submission.Create(command.Id, command.ConferenceId, command.Title, command.Description, command.Level, command.Tags, speakers); await _submissionRepository.AddAsync(submission); }
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()); }