private async Task ProcessBrandChoice(IDialogContext context, IAwaitable <object> awaitable)
        {
            Activity reply, ans = (Activity)(await awaitable);
            string   brand = ans.Text;


            if ((brand.Length > 7) && (brand.StartsWith("I want ")))
            {
                brand = brand.Substring(7).ToLower();
            }
            if (handSetsBag.IsBrandUnavailable(brand))
            {
                reply = ans.CreateReply("I'm sorry, unfortunately we do not have that brand available, would it be possible to pick another one?");
                Miscellany.ComposeBrandsCarousel(reply, handSetsBag.GetAllBrands().Keys, handSetsBag);
                await Miscellany.InsertDelayAsync(context);

                await context.PostAsync(reply);
            }
            else if (!handSetsBag.GetAllBrands().Keys.Contains(brand))
            {
                reply = ans.CreateReply("I'm sorry, unfortunately I don't know that brand, would it be possible to pick another one?");
                Miscellany.ComposeBrandsCarousel(reply, handSetsBag.GetAllBrands().Keys, handSetsBag);
                await Miscellany.InsertDelayAsync(context);

                await context.PostAsync(reply);
            }
            else
            {
                decoder.StrKeyWords = new List <string> {
                    brand.ToLower()
                };
                context.Wait(MessageReceived);
                await DecodeAndProcessIntentAsync(context);
            }
        }
Esempio n. 2
0
        protected Dictionary <string, bool> GetAllBrands()
        {
            Dictionary <string, bool> brandSet;

            if (handSets == null)
            {
                InitializeDataStruct();
            }
            brandSet = handSets.GetAllBrands();

            return(brandSet);
        }