コード例 #1
0
        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);
        }
コード例 #2
0
        public async Task get_browse_attendances_given_valid_conference_and_participant_should_return_all_attendances()
        {
            var from            = DateTime.UtcNow;
            var to              = from.AddDays(1);
            var conferenceId    = Guid.NewGuid();
            var userId          = Guid.NewGuid();
            var participant     = new Participant(Guid.NewGuid(), conferenceId, userId);
            var slot            = new Slot(Guid.NewGuid(), participant.Id);
            var attendableEvent = new AttendableEvent(Guid.NewGuid(), conferenceId, from, to, new[] { slot });
            var attendance      = new Attendance(Guid.NewGuid(), attendableEvent.Id, slot.Id, participant.Id, from, to);

            await _dbContext.AttendableEvents.AddAsync(attendableEvent);

            await _dbContext.Attendances.AddAsync(attendance);

            await _dbContext.Participants.AddAsync(participant);

            await _dbContext.Slots.AddAsync(slot);

            await _dbContext.SaveChangesAsync();

            _agendasApiClient.GetAgendaAsync(conferenceId).Returns(new List <AgendaTrackDto>
            {
                new()
                {
                    Id           = Guid.NewGuid(),
                    Name         = "Track 1",
                    ConferenceId = conferenceId,
                    Slots        = new[]
                    {
                        new RegularAgendaSlotDto
                        {
                            Id         = Guid.NewGuid(),
                            From       = from,
                            To         = to,
                            AgendaItem = new AgendaItemDto
                            {
                                Id          = attendableEvent.Id,
                                Title       = "test",
                                Description = "test",
                                Level       = 1
                            }
                        }
                    }
                }
            });
コード例 #3
0
 public async Task UpdateAsync(AttendableEvent attendableEvent)
 {
     _attendableEvents.Update(attendableEvent);
     await _context.SaveChangesAsync();
 }
コード例 #4
0
        public async Task AddAsync(AttendableEvent attendableEvent)
        {
            await _attendableEvents.AddAsync(attendableEvent);

            await _context.SaveChangesAsync();
        }
コード例 #5
0
 public AttendableEvent_Attend_Tests()
 {
     _attendableEvent = new AttendableEvent(Guid.NewGuid(), _conferenceId,
                                            new DateTime(2020, 4, 1, 9, 0, 0),
                                            new DateTime(2020, 4, 1, 10, 0, 0));
 }