示例#1
0
        private async Task <IEnumerable <Food> > GetFoodAsync(SelectFoodType searchQuery)
        {
            var returnList = new List <Food>();

            string[] listToUse = null;
            switch (searchQuery.FoodType.ToLower())
            {
            case "burger":
                listToUse = burgertype;
                break;

            case "fries":
                listToUse = friestype;
                break;
            }

            for (int i = 0; i < listToUse.Length; i++)
            {
                var  random = new Random(i);
                Food food   = new Food()
                {
                    Name          = $"{listToUse[i]} {searchQuery.FoodType}",
                    PriceStarting = random.Next(80, 450),
                    Image         = $"https://placeholdit.imgix.net/~text?txtsize=35&txt={listToUse[i]}+{i}&w=500&h=260"
                };

                returnList.Add(food);
            }

            returnList.Sort((h1, h2) => h1.PriceStarting.CompareTo(h2.PriceStarting));

            return(returnList);
        }
示例#2
0
        public async Task Order(IDialogContext dialogContext, IAwaitable <IMessageActivity> activity, LuisResult result)
        {
            previous_state = "ORDER";
            var message = await activity;

            if (displayWelcome)
            {
                await dialogContext.PostAsync($"Welcome to chatbot for restaurants! We are analyzing your message: '{message.Text}'...");
            }
            displayWelcome = false;

            var foodQuery = new SelectFoodType();
            EntityRecommendation foodentityRecommendation;

            if (result.TryFindEntity(EntityBurgerType, out foodentityRecommendation))
            {
                foodentityRecommendation.Type = "FoodType";
            }

            var BurgerFormDialog = new FormDialog <SelectFoodType>(foodQuery, this.BuildFoodForm, FormOptions.PromptInStart, result.Entities);

            dialogContext.Call(BurgerFormDialog, this.ResumeAfterFoodFormDialog);
        }