public async Task <IActionResult> PostEventAsync(ConferenceEventRequest request)
        {
            Guid.TryParse(request.ConferenceId, out var conferenceId);
            Guid.TryParse(request.ParticipantId, out var participantId);

            var command = EventRequestMapper.MapEventRequestToEventCommand(conferenceId, request);

            _logger.LogWarning("Handling {ConferenceEventRequest}", nameof(ConferenceEventRequest));

            await _commandHandler.Handle(command);

            if (request.ShouldSkipEventHandler())
            {
                _logger.LogDebug("Handling CallbackEvent skipped due to result of ShouldHandleEvent");
                return(NoContent());
            }

            var callbackEvent = EventRequestMapper.MapEventRequestToEventHandlerDto(conferenceId, participantId, request);
            await _eventHandlerFactory.Get(callbackEvent.EventType).HandleAsync(callbackEvent);

            return(NoContent());
        }
Exemple #2
0
        public async Task <IActionResult> PostEventAsync(ConferenceEventRequest request)
        {
            Guid.TryParse(request.ConferenceId, out var conferenceId);

            var command = new SaveEventCommand(conferenceId, request.EventId, request.EventType,
                                               request.TimeStampUtc, request.TransferFrom, request.TransferTo, request.Reason, request.Phone);

            if (Guid.TryParse(request.ParticipantId, out var participantId))
            {
                command.ParticipantId = participantId;
            }

            _logger.LogWarning("Handling {ConferenceEventRequest}", nameof(ConferenceEventRequest));

            await _commandHandler.Handle(command);

            if (request.ShouldSkipEventHandler())
            {
                _logger.LogDebug("Handling CallbackEvent skipped due to result of ShouldHandleEvent.");
                return(NoContent());
            }

            var callbackEvent = new CallbackEvent
            {
                EventId       = request.EventId,
                EventType     = request.EventType,
                ConferenceId  = conferenceId,
                Reason        = request.Reason,
                TransferTo    = request.TransferTo,
                TransferFrom  = request.TransferFrom,
                TimeStampUtc  = request.TimeStampUtc,
                ParticipantId = participantId,
                Phone         = request.Phone
            };
            await _eventHandlerFactory.Get(request.EventType).HandleAsync(callbackEvent);

            return(NoContent());
        }