public async Task HandleAsync(SpeakerCreated @event)
        {
            if (await _speakerRepository.ExistsAsync(@event.Id))
            {
                return;
            }

            var speaker = Speaker.Create(@event.Id, @event.FullName);
            await _speakerRepository.AddAsync(speaker);
        }
Exemple #2
0
        public async Task CreateAsync(SpeakerDto speaker)
        {
            var alreadyExists = await _speakerRepository.ExistsAsync(speaker.Id);

            if (alreadyExists)
            {
                throw new SpeakerAlreadyExistsException(speaker.Id);
            }

            await _speakerRepository.AddAsync(speaker.AsEntity());

            await _messageBroker.PublishAsync(new SpeakerCreated(speaker.Id, speaker.FullName));
        }