public async Task HandleAsync(AgendaItemAssignedToAgendaSlot @event)
        {
            var attendableEvent = await _attendableEventsRepository.GetAsync(@event.AgendaItemId);

            if (attendableEvent is not null)
            {
                return;
            }

            var slot = await _agendasApiClient.GetRegularAgendaSlotAsync(@event.AgendaItemId);

            if (slot is null)
            {
                throw new AttendableEventNotFoundException(@event.AgendaItemId);
            }

            if (!slot.ParticipantsLimit.HasValue)
            {
                return;
            }

            attendableEvent = new AttendableEvent(@event.AgendaItemId, slot.AgendaItem.ConferenceId, slot.From, slot.To);
            var slotPolicy = _slotPolicyFactory.Get(slot.AgendaItem.Tags.ToArray());
            var slots      = slotPolicy.Generate(slot.ParticipantsLimit.Value);

            attendableEvent.AddSlots(slots);
            await _attendableEventsRepository.AddAsync(attendableEvent);
        }
Ejemplo n.º 2
0
        public async Task HandleAsync(AttendEvent command)
        {
            var attendableEvent = await _attendableEventsRepository.GetAsync(command.Id);

            if (attendableEvent is null)
            {
                throw new AttendableEventNotFoundException(command.Id);
            }

            var participant = await _participantsRepository
                              .GetAsync(attendableEvent.ConferenceId, command.ParticipantId);

            if (participant is null)
            {
                throw new ParticipantNotFoundException(attendableEvent.ConferenceId, command.ParticipantId);
            }

            attendableEvent.Attend(participant);
            await _participantsRepository.UpdateAsync(participant);

            await _attendableEventsRepository.UpdateAsync(attendableEvent);
        }