Ejemplo n.º 1
0
        public async Task Compare(IDialogContext context)
        {
            // fetch products
            var itemsToCompare = StateHelper.GetComparatorItems(context);

            foreach (string o in itemsToCompare)
            {
                products.Add(ProductController.getProduct(o.ToString()));
            }

            if (products.Count > 0)
            {
                var reply = context.MakeMessage();
                reply.Text = Interactions.getOngoingComp();
                await context.PostAsync(reply);

                ComparatorLogic.ShowProductComparison(context, products);

                /*
                 * //show options
                 * if(products.Count <= ComparatorLogic.MAX_PRODUCTS_ON_COMPARATOR)
                 * {
                 *  reply = context.MakeMessage();
                 *  reply.Attachments.Add(getCardButtonsAttachment(
                 *      new List<ButtonType> { ButtonType.ADD_PRODUCT }, DialogType.COMPARE));
                 *  await context.PostAsync(reply);
                 * }*/
            }
            else
            {
                await context.PostAsync("Não tem produtos para comparar.");

                //show options
                var reply = context.MakeMessage();
                reply.Attachments.Add(getCardButtonsAttachment(
                                          new List <ButtonType> {
                    ButtonType.ADD_PRODUCT
                }, DialogType.COMPARE));
                await context.PostAsync(reply);
            }
        }