Esempio n. 1
0
        public async Task StartAsync(IDialogContext context)
        {
            var state = new VerticalChoiceForm();

            var form = new FormDialog <VerticalChoiceForm>(
                state,
                BuildForm,
                FormOptions.PromptInStart);

            context.Call(form, this.AfterBuildForm);
        }
Esempio n. 2
0
        private async Task AfterBuildForm(IDialogContext context, IAwaitable <object> result)
        {
            try
            {
                var o = await result;

                if (o.GetType() == typeof(VerticalChoiceForm))
                {
                    VerticalChoiceForm verticalChoiceForm = await result as VerticalChoiceForm;

                    if (verticalChoiceForm.VerticalA.HasValue)
                    {
                        context.UserData.SetValue <int>(ContextKeys.VerticalId, (int)verticalChoiceForm.VerticalA.Value);
                    }
                    else if (verticalChoiceForm.VerticalB.HasValue)
                    {
                        context.UserData.SetValue <int>(ContextKeys.VerticalId, (int)verticalChoiceForm.VerticalB.Value);
                    }
                    else if (verticalChoiceForm.VerticalC.HasValue)
                    {
                        context.UserData.SetValue <int>(ContextKeys.VerticalId, (int)verticalChoiceForm.VerticalC.Value);
                    }

                    context.Done(verticalChoiceForm);
                }
                else
                {
                    context.Done("ERROR");
                }
            }
            catch (FormCanceledException ex)
            {
                context.Done("QUIT");
            }
            catch (Exception ex)
            {
                await context.PostAsync("I'm sorry, Vertical Choice Form encountered a problem.");

                context.Done("ERROR");
            }
        }