예제 #1
0
        public async Task <IActionResult> UpdateParticipantStatusAsync(Guid conferenceId,
                                                                       UpdateParticipantStatusEventRequest updateParticipantStatusEventRequest)
        {
            var conference = await _conferenceCache.GetOrAddConferenceAsync(conferenceId, () =>
            {
                _logger.LogTrace($"Retrieving conference details for conference: ${conferenceId}");

                return(_videoApiClient.GetConferenceDetailsByIdAsync(conferenceId));
            });

            var username               = User.Identity.Name;
            var participantId          = GetIdForParticipantByUsernameInConference(conference, username);
            var conferenceEventRequest = new ConferenceEventRequest
            {
                Conference_id  = conferenceId.ToString(),
                Participant_id = participantId.ToString(),
                Event_id       = Guid.NewGuid().ToString(),
                Event_type     = updateParticipantStatusEventRequest.EventType,
                Time_stamp_utc = DateTime.UtcNow,
                Reason         = EventTypeReasonMapper.Map(updateParticipantStatusEventRequest.EventType)
            };

            var callbackEvent =
                CallbackEventMapper.MapConferenceEventToCallbackEventModel(conferenceEventRequest, conference);
            var handler = _eventHandlerFactory.Get(callbackEvent.EventType);

            try
            {
                await handler.HandleAsync(callbackEvent);
            }
            catch (ConferenceNotFoundException)
            {
                return(BadRequest());
            }

            try
            {
                await _videoApiClient.RaiseVideoEventAsync(conferenceEventRequest);

                return(NoContent());
            }
            catch (VideoApiException e)
            {
                return(StatusCode(e.StatusCode, e.Response));
            }
        }
        public void Should_set_reason_to_participant_not_signed_in()
        {
            var eventType = EventType.ParticipantNotSignedIn;

            EventTypeReasonMapper.Map(eventType).Should().Be("participant not signed in");
        }
        public void Should_set_reason_to_empty()
        {
            var eventType = EventType.None;

            EventTypeReasonMapper.Map(eventType).Should().Be(string.Empty);
        }
        public void Should_set_reason_for_event_type_joined()
        {
            var eventType = EventType.ParticipantJoining;

            EventTypeReasonMapper.Map(eventType).Should().Be("participant joining");
        }