Esempio n. 1
0
        public async Task MessageReceivedAsync(IDialogContext context, IAwaitable <IMessageActivity> argument)
        {
            var message = await argument;

            if (message.IsValidTextMessage())
            {
                try
                {
                    var json   = JObject.Parse(message.Text);
                    var action = json.GetValue("ActionType");
                    switch (action.ToString())
                    {
                    case BotActionTypes.ContinueShopping:
                        await context.PostAsync(TextResources.You_can_continue_shopping);

                        context.Done <object>(false);
                        break;

                    case BotActionTypes.BasketCheckout:
                        context.Call(dialogFactory.CreateOrderDialog(), AfterOrderAsync);
                        break;
                    }
                }
                catch (JsonReaderException)
                {
                    // is not a Json
                    await context.PostAsync(TextResources.Please_make_a_selection);

                    context.Wait(MessageReceivedAsync);
                }
            }
            else
            {
                // file sent
                await context.PostAsync(TextResources.Please_make_a_selection);

                context.Wait(MessageReceivedAsync);
            }
        }