Ejemplo n.º 1
0
        public async Task <IActionResult> ProcessAsync()
        {
            await _eventsTable.CreateIfNotExistsAsync();

            try
            {
                Validator.ValidateRequest(_joinMeetingRequest);

                var events = _eventsTable
                             .CreateQuery <EventDto>()
                             .AsQueryable()
                             .Where(e => e.RowKey == _joinMeetingRequest.EventId)
                             .ToArray();

                if (events.Length == 0 || !events[0].EventGuests.Contains(_loginUserEmail))
                {
                    return(new NotFoundResult());
                }

                var @event = events[0];

                await TwilioService.CreateMeetingRoomAsync(@event);

                var meetingRoomToken = TwilioService.GetMeetingRoomJoinToken(@event, _loginUserEmail);

                _logger.LogInformation("User {0} joined meeting for event {1}", _loginUserEmail, @event.RowKey);

                return(new OkObjectResult(new { @event, meetingRoomToken }));
            }
            catch (ValidationException e)
            {
                return(new BadRequestObjectResult(new { errors = e.Message }));
            }
        }