Ejemplo n.º 1
0
        private Attachment GetReceiptCard()
        {
            HabitatHomeService obj = new HabitatHomeService();
            var listtopProduct     = obj.MiniCart();
            var receiptItems       = new List <ReceiptItem>();

            foreach (Line topProduct in listtopProduct.Result.Lines)
            {
                var receiptItem = new ReceiptItem(
                    title: Truncate(topProduct.DisplayName, 15),
                    quantity: topProduct.Quantity,
                    price: topProduct.LinePrice,
                    image: new CardImage(StringConstants.HostUrl + topProduct.Image));

                receiptItems.Add(receiptItem);
            }
            var receiptCard = new ReceiptCard()
            {
                Title = Resources.ShowCartDialog_MiniCart_Title,
                Items = receiptItems,
                Tax   = listtopProduct.Result.TaxTotal,
                Total = listtopProduct.Result.Total
            };

            return(receiptCard.ToAttachment());
        }
Ejemplo n.º 2
0
        public override async Task ProcessMessageReceived(IDialogContext context, string message)
        {
            string[] productParam = message.Split('|');
            bool     resultjson   = false;

            if (productParam.Length >= 3)
            {
                await context.PostAsync("OK, Please wait .. Let me add the product to your cart");

                HabitatHomeService obj = new HabitatHomeService();
                resultjson = obj.AddProduct(productParam[1], productParam[2]);
            }
            if (resultjson)
            {
                await context.PostAsync($"Your product '{productParam[0]}' has been added to the cart");

                context.Done(resultjson);
            }
            else
            {
                await context.PostAsync(string.Format(CultureInfo.CurrentCulture, Resources.ProductsDialog_InvalidOption, productParam[0]));

                await this.ShowProducts(context);

                context.Wait(this.MessageReceivedAsync);
            }
        }
Ejemplo n.º 3
0
        public override PagedCarouselCards GetCarouselCards(int pageNumber, int pageSize)
        {
            HabitatHomeService habitatHomeService = new HabitatHomeService();
            var listtopProduct = habitatHomeService.TopProduct();
            var carouselCards  = listtopProduct.Result.Select(topProduct => new HeroCard
            {
                Title    = topProduct.DisplayName,
                Subtitle = topProduct.Description,
                Text     = topProduct.ListPriceWithCurrency,
                Images   = new List <CardImage> {
                    new CardImage(StringConstants.HostUrl + topProduct.SummaryImageUrl, topProduct.DisplayName)
                },
                Buttons = new List <CardAction>
                {
                    new CardAction(ActionTypes.ImBack, title: Resources.ProductsDialog_Select, displayText: topProduct.DisplayName,
                                   value: topProduct.DisplayName + "|" + topProduct.CatalogName + "|" + topProduct.ProductId)
                }
            });

            TotalCount = listtopProduct.Result.Count;

            return(new PagedCarouselCards
            {
                Cards = carouselCards,
                TotalCount = listtopProduct.Result.Count
            });
        }
Ejemplo n.º 4
0
        private async Task CreateOrderStep(IDialogContext dialogContext)
        {
            await dialogContext.PostAsync(PleaseWaitYourOrderIsProcessingMessage);

            HabitatHomeService obj = new HabitatHomeService();

            string orderResult = obj.CreateOrder().Result;
            await dialogContext.PostAsync(orderResult);

            dialogContext.Done(orderResult);
        }