示例#1
0
        public ThumbnailSalesCardList(string product, int numberCustomers, int month, List <CustomerSales> salesData, BotCommand <int> prevMonth, BotCommand <int> nextMonth)
        {
            var titleCard = new ThumbnailCard()
            {
                Title = $"{Utils.GetMonthName (month)} - {product.ToTitleCase ()}"
            };

            Add(titleCard);

            foreach (var customerSalesData in salesData)
            {
                var card = new ThumbnailCard()
                {
                    Title    = $"{customerSalesData.Customer}",
                    Subtitle = $"{customerSalesData.TotalSales:C}"
                };

                Add(card);
            }

            var cardButtons = new List <CardAction> ();

            var prevButton = new CardAction()
            {
                Value = prevMonth.RenderActionEvent(),
                Type  = "postBack",
                Title = prevMonth.Label
            };

            cardButtons.Add(prevButton);

            var nextButton = new CardAction()
            {
                Value = nextMonth.RenderActionEvent(),
                Type  = "postBack",
                Title = nextMonth.Label
            };

            cardButtons.Add(nextButton);

            var buttonCard = new ThumbnailCard()
            {
                Buttons = cardButtons
            };

            Add(buttonCard);
        }
        public AdaptiveSalesCard(string product, int numberCustomers, int month, List <CustomerSales> salesData, BotCommand <int> prevMonth, BotCommand <int> nextMonth)
        {
            var facts = new List <AdaptiveFact> ();

            foreach (var customerSalesData in salesData)
            {
                facts.Add(new AdaptiveFact(customerSalesData.Customer, String.Format("{0:C}", customerSalesData.TotalSales)));
            }

            Body = new List <AdaptiveElement> ()
            {
                new AdaptiveContainer()
                {
                    Items =
                    {
                        new AdaptiveTextBlock()
                        {
                            Text   = $"{Utils.GetMonthName(month)} - {product.ToTitleCase()}",
                            Size   = AdaptiveTextSize.ExtraLarge,
                            Weight = AdaptiveTextWeight.Bolder
                        },
                        new AdaptiveFactSet()
                        {
                            Facts = facts
                        }
                    }
                }
            };

            Actions.Add(
                new AdaptiveSubmitAction()
            {
                Title    = prevMonth.Label,
                DataJson = prevMonth.RenderActionEvent()
            }
                );

            Actions.Add(
                new AdaptiveSubmitAction()
            {
                Title    = nextMonth.Label,
                DataJson = nextMonth.RenderActionEvent()
            }
                );
        }