Пример #1
0
        protected override Task <TwilioResponseResult> HandleSelectionInternal(string phoneNumber, string selection)
        {
            var newGroupName = Name;

            int selectedOptionNumber;

            if (int.TryParse(selection, out selectedOptionNumber))
            {
                var selectedOptionName = _options.Skip(selectedOptionNumber - 1).FirstOrDefault();
                newGroupName = selectedOptionName ?? newGroupName;
            }

            return(Task.FromResult <TwilioResponseResult>(
                       new TwilioRedirectResult(TwilioVoiceController.GetBrowseUrl(newGroupName))));
        }
Пример #2
0
        public async Task <TwilioResponseResult> HandleSelection(string phoneNumber, string selection)
        {
            if (selection == "#")
            {
                return(new TwilioRedirectResult(TwilioVoiceRoutes.MainMenu));
            }

            if (selection == "*")
            {
                return(new TwilioRedirectResult(TwilioVoiceController.GetBrowseUrl(_topGroupName)));
            }

            if (selection == "0")
            {
                return(new TwilioRedirectResult(TwilioVoiceController.GetBrowseUrl(ParentName, true)));
            }

            return(await HandleSelectionInternal(phoneNumber, selection));
        }
Пример #3
0
        public async Task <TwilioResponseResult> HandleBrowseAsync(string phoneNumber, bool navigatingUp)
        {
            if (NumberOfOptions == 1)
            {
                return(navigatingUp ?
                       new TwilioRedirectResult(TwilioVoiceController.GetBrowseUrl(ParentName, true)) :
                       await HandleSelection(phoneNumber, 1.ToString()));
            }

            var numDigits = NumberOfOptions == 0 ?
                            0 :
                            Convert.ToInt32(Math.Floor(Math.Log10(NumberOfOptions))) + 1;

            return(new TwilioResponseResult(response =>
            {
                response.BeginGather(new
                {
                    action = TwilioVoiceController.GetBrowseUrl(Name),
                    numDigits = numDigits,
                    timeout = 2,
                    finishOnKey = ""
                });

                response.AliceSay(Name);
                response.Pause();

                HandleBrowseInternal(response);

                if (ParentName != null)
                {
                    response.AliceSay(string.Concat("Press 0 to exit ", Name, "."));
                    response.AliceSay("Press star to go elsewhere.");
                }

                response.AliceSay("Press pound for main menu.");
                response.EndGather();
                response.Redirect();
            }));
        }