Пример #1
0
        /// <summary>
        /// Creates the extended security check dialog.
        /// </summary>
        /// <returns>Returns the dialog structure.</returns>
        private Dialog CreateExtendedSecurityCheckDialog()
        {
            var steps = new WaterfallStep[]
            {
                async(stepContext, cancellationToken) =>
                {
                    var card = new ReceiptCard
                    {
                        Title = "Extended security check",
                        Items = new List <ReceiptItem>
                        {
                            new ReceiptItem(title: "Luggage check", quantity: "1"),
                            new ReceiptItem(title: "Extended personal security check", quantity: "1"),
                        },
                        Tax   = "12 credits",
                        Total = "75 credits",
                    };

                    var receiptMessage = MessageFactory.Attachment(
                        card.ToAttachment(),
                        "Okay, well, here's a receipt, please follow Al for an additional security check.");

                    await stepContext.Context.SendActivityAsync(receiptMessage);

                    await stepContext.Context.SendActivityAsync("Have a pleasant security check!");

                    return(await stepContext.EndDialogAsync());
                },
            };

            return(new WaterfallDialog(DialogNames.ExtendedSecurityCheckDialog, steps));
        }
Пример #2
0
        private static Attachment GetReceiptCard()
        {
            var receiptCard = new ReceiptCard
            {
                Title = "Заголовок Receipt Card",
                Facts = new List <Fact> {
                    new Fact("Номер заказа", "1234"), new Fact("Метод оплаты", "VISA 5555-****")
                },
                Items = new List <ReceiptItem>
                {
                    new ReceiptItem("Обмен данными", price: "$ 38.45", quantity: "368", image: new CardImage(url: "https://github.com/amido/azure-vector-icons/raw/master/renders/traffic-manager.png")),
                    new ReceiptItem("Служба приложений", price: "$ 45.00", quantity: "720", image: new CardImage(url: "https://github.com/amido/azure-vector-icons/raw/master/renders/cloud-service.png")),
                },
                Tax     = "$ 7.50",
                Total   = "$ 90.95",
                Buttons = new List <CardAction>
                {
                    new CardAction(
                        ActionTypes.OpenUrl,
                        "Больше информации",
                        "https://account.windowsazure.com/content/6.10.1.38-.8225.160809-1618/aux-pre/images/offer-icon-freetrial.png",
                        "https://azure.microsoft.com/en-us/pricing/")
                }
            };

            return(receiptCard.ToAttachment());
        }
Пример #3
0
        private static Attachment BuildReceiptCard(IrishMQResultsBreakdown breakdown)
        {
            try
            {
                var receiptCard = new ReceiptCard
                {
                    Title = $"Insurer: {breakdown.Premium.SchemeName}",
                    Facts = new List <Fact> {
                        new Fact("Scheme", breakdown.Premium.Scheme.SchemeNumber)
                    },
                    Tax     = $"€{breakdown.Premium.PremiumAfterLevy - breakdown.Premium.PremiumBeforeLevy}",
                    Total   = $"€{breakdown.Premium.TotalPremium}",
                    Buttons = new List <CardAction>
                    {
                        new CardAction
                        (
                            ActionTypes.PostBack,
                            "Request a Callback"
                        )
                    }
                };

                return(receiptCard.ToAttachment());
            }
            catch (Exception exception)
            {
                ErrorRepository.LogError(DateTime.Now.ToString(new CultureInfo("en-GB")), exception.ToString());
                throw;
            }
        }
Пример #4
0
        private static Attachment GetReceiptCard(HomeQuoteWebServiceResult homeQuoteWebServiceResult)
        {
            try
            {
                var receiptCard = new ReceiptCard
                {
                    Title = $"{homeQuoteWebServiceResult.InsurerName}",
                    Facts = new List <Fact> {
                        new Fact("Scheme", homeQuoteWebServiceResult.SchemeName)
                    },
                    Tax     = $"€{homeQuoteWebServiceResult.GovernmentLevyPremium}",
                    Total   = $"€{homeQuoteWebServiceResult.NetPremium}",
                    Buttons = new List <CardAction>
                    {
                        new CardAction
                        (
                            ActionTypes.PostBack,
                            "Request a Callback"
                        )
                    }
                };

                return(receiptCard.ToAttachment());
            }
            catch (Exception exception)
            {
                ErrorRepository.LogError(DateTime.Now.ToString(new CultureInfo("en-GB")), exception.ToString());
                throw;
            }
        }
Пример #5
0
        //3
        private static Attachment GetReceiptCard()
        {
            var heroCard = new ReceiptCard()
            {
                Title = "Receipt Card",
                Facts = new List <Fact> {
                    new Fact("Номер заказа", "34221543"), new Fact("Метод оплаты", "VISA 1234-****-****")
                },
                Items = new List <ReceiptItem>
                {
                    new ReceiptItem("Обмен данными", price: "$ 10.50", quantity: "388", image: new CardImage(url: "https://github.com/amido/azure-vector-icons/blob/master/icons/Azure%20Active%20Directory%20(AAD).svg")),
                    new ReceiptItem("Sluzhba prilozheniy", price: "$ 100.00", quantity: "1000", image: new CardImage(url: "https://github.com/amido/azure-vector-icons/blob/master/icons/Azure%20Active%20Directory%20Access%20Control%20Services%20(ACS).svg"))
                },
                Tax     = "$ 5.50",
                Total   = "$ 116.00",
                Buttons = new List <CardAction>
                {
                    new CardAction(ActionTypes.OpenUrl, "More info",
                                   "http://geek-nose.com/wp-content/uploads/2016/01/kak-ustanovit-prilozhenie-na-android-s-kompjutera-№12.jpg",
                                   "https://dev.botframework.com")
                }
            };

            return(heroCard.ToAttachment());
        }
Пример #6
0
        private Attachment RecipeCard(IDialogContext context, Basket basket)
        {
            var checkoutButton = new CardAction()
            {
                Type  = ActionTypes.PostBack,
                Value = $@"{{ 'ActionType': '{BotActionTypes.BasketCheckout}'}}",
                Title = "Checkout"
            };

            var continueShoppingButton = new CardAction()
            {
                Type  = ActionTypes.PostBack,
                Value = $@"{{ 'ActionType': '{BotActionTypes.ContinueShopping}'}}",
                Title = "Continue shopping"
            };
            var cardButtons = new List <CardAction>
            {
                checkoutButton,
                continueShoppingButton
            };

            decimal total = basket.Items.Sum(i => i.UnitPrice * i.Quantity);

            var basketCard = new ReceiptCard()
            {
                Title   = "eShopAI receipt",
                Buttons = cardButtons,
                Items   = UIHelper.CreateOrderBasketItemListReceipt(basket.Items),
                Total   = $"{total} $"
            };

            return(basketCard.ToAttachment());
        }
Пример #7
0
        private List <Attachment> ReceiptOrders(IMessageActivity reply, List <Order> orders)
        {
            var attachements = new List <Attachment>();

            foreach (var order in orders)
            {
                var orderDetailsButtons = new List <CardAction>
                {
                    new CardAction()
                    {
                        Type  = ActionTypes.PostBack,
                        Value = $@"{{ 'ActionType': '{BotActionTypes.OrderDetail}', 'OrderNumber': '{order.OrderNumber}' }}",
                        Title = "Detail"
                    }
                };

                var orderDetailsCard = new ReceiptCard()
                {
                    Title   = $"Order Details",
                    Facts   = BuildOrderFacts(order),
                    Buttons = orderDetailsButtons,
                    Total   = $"{order.Total} $"
                };

                attachements.Add(orderDetailsCard.ToAttachment());
            }
            return(attachements);
        }
Пример #8
0
        private static Attachment GetReceiptCard()
        {
            var receiptCard = new ReceiptCard
            {
                Title = "John Doe",
                Facts = new List <Fact> {
                    new Fact("Order Number", "1234"), new Fact("Payment Method", "VISA 5555-****")
                },
                Items = new List <ReceiptItem>
                {
                    new ReceiptItem("Data Transfer", price: "$ 38.45", quantity: "368", image: new CardImage(url: "https://github.com/amido/azure-vector-icons/raw/master/renders/traffic-manager.png")),
                    new ReceiptItem("App Service", price: "$ 45.00", quantity: "720", image: new CardImage(url: "https://github.com/amido/azure-vector-icons/raw/master/renders/cloud-service.png")),
                },
                Tax     = "$ 7.50",
                Total   = "$ 90.95",
                Buttons = new List <CardAction>
                {
                    new CardAction(
                        ActionTypes.OpenUrl,
                        "More information",
                        "https://account.windowsazure.com/content/6.10.1.38-.8225.160809-1618/aux-pre/images/offer-icon-freetrial.png",
                        "https://azure.microsoft.com/en-us/pricing/")
                }
            };

            return(receiptCard.ToAttachment());
        }
Пример #9
0
        //since currently global variables are used to store entities and active account, there is no need for parameters in this method
        //however, future refactoring is planned for the project.
        private Attachment GetReceiptCard()
        {
            var receiptCard = new ReceiptCard
            {
                Title = "Funds Transferred",
                Facts = new List <Fact> {
                    new Fact("From", _sourceAccount.Name), new Fact("To", _targetAccount.Name)
                },
                //Items = new List<ReceiptItem>
                //{
                //    new ReceiptItem("Fund Transfer", price: $"{_amount:C}", , image: new CardImage(url: "https://d30y9cdsu7xlg0.cloudfront.net/png/3050-200.png")),
                //},
                Tax     = "You wish",
                Total   = $"{_amount:C}",
                Buttons = new List <CardAction>
                {
                    new CardAction(
                        ActionTypes.OpenUrl,
                        "View online",
                        "http://example.com/")
                }
            };

            return(receiptCard.ToAttachment());
        }
        private Activity DisplayAccount(List <Account> accounts, Activity activity)
        {
            Activity replyToConversation = activity.CreateReply("");

            replyToConversation.Recipient   = activity.From;
            replyToConversation.Type        = "message";
            replyToConversation.Attachments = new List <Attachment>();
            List <ReceiptItem> items = new List <ReceiptItem>();

            decimal total = 0;

            foreach (Account acc in accounts)
            {
                total += acc.Value;
                ReceiptItem item = new ReceiptItem()
                {
                    Title    = acc.Name,
                    Subtitle = acc.Type,
                    Price    = acc.Value.ToString()
                };
                items.Add(item);
            }

            ReceiptCard Card = new ReceiptCard()
            {
                Title = "Accounts",
                Items = items,
                Total = total.ToString()
            };

            Attachment plAttachment = Card.ToAttachment();

            replyToConversation.Attachments.Add(plAttachment);
            return(replyToConversation);
        }
Пример #11
0
        public Task StartAsync(IDialogContext context)
        {
            var receiptCard = new ReceiptCard()
            {
                Title = "訂房費用",
                Total = "NT$ 120",
                Tax   = "NT$ 20",
                Items = new List <ReceiptItem>()
                {
                    new ReceiptItem()
                    {
                        Title    = "1大房",
                        Price    = "90",
                        Quantity = "1",
                        Image    = new CardImage("https://cdn.pixabay.com/photo/2014/08/11/21/40/wall-416062__180.jpg")
                    },
                    new ReceiptItem()
                    {
                        Title    = "飲料",
                        Price    = "10",
                        Quantity = "1",
                        Image    = new CardImage("https://cdn.pixabay.com/photo/2014/09/26/19/51/coca-cola-462776_1280.jpg")
                    }
                }
            };

            context.Done(receiptCard.ToAttachment());

            return(Task.CompletedTask);
        }
Пример #12
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());
        }
Пример #13
0
        public static Attachment GetReceiptCard()
        {
            var receiptCard = new ReceiptCard
            {
                Title = "Mumbai Journey",

                Items = new List <ReceiptItem>
                {
                    new ReceiptItem("Air Plane", price: "Upto 8000 Rs: ", quantity: "1", image: new CardImage(url: "https://www.google.co.in/search?q=airplane+images&source=lnms&tbm=isch&sa=X&ved=0ahUKEwi65JXqtubZAhUMlJQKHcyBA64Q_AUICigB&biw=1407&bih=655#imgrc=VjENmwnfXxIMZM:")),
                    new ReceiptItem("Train", price: "$ 45.00", quantity: "1", image: new CardImage(url: "https://github.com/amido/azure-vector-icons/raw/master/renders/cloud-service.png")),
                },
                Tax     = "$ 7.50",
                Total   = "$ 90.95",
                Buttons = new List <CardAction>
                {
                    new CardAction(
                        ActionTypes.OpenUrl,
                        "More information",
                        "https://account.windowsazure.com/content/6.10.1.38-.8225.160809-1618/aux-pre/images/offer-icon-freetrial.png",
                        "https://azure.microsoft.com/en-us/pricing/")
                }
            };

            return(receiptCard.ToAttachment());
        }
Пример #14
0
        private async Task <Attachment> GetReceiptCard(ReservationData reservation)
        {
            var price = await priceService.GetRidePriceEstimate(reservation.Location);

            var pickupTime  = reservation.Time;
            var receiptCard = new ReceiptCard()
            {
                Title = "Ride Sharing Receipt",
                // steps
                Facts = new List <Fact>
                {
                    new Fact("Booking Number", "000345"),
                    new Fact("Customer", "Lance Olson"),
                    new Fact("Payment Method", "VISA 5555-****")
                },
                Items = new List <ReceiptItem>
                {
                    new ReceiptItem(title: reservation.CarType, subtitle: pickupTime, price: price, quantity: "1", image: new CardImage(BotConstants.CarImageUrl))
                },
                Tax     = "$ 5.50",
                Total   = price,
                Buttons = new List <CardAction>
                {
                    new CardAction()
                    {
                        Type  = ActionTypes.OpenUrl,
                        Title = "More information",
                        Image = BotConstants.CompanyLogoUrl,
                        Value = "https://azure.microsoft.com/en-us/pricing/"
                    }
                }
            };

            return(receiptCard.ToAttachment());
        }
Пример #15
0
        private async static Task FormCompleted(IDialogContext context, PriceCalculationForm state)
        {
            var priceCalculator = new StubPriceCalculator();
            var price           = priceCalculator.GetPrice(state.RouteFrom, state.RouteTo, state.LoadingDate, state.CargoTypeCode, state.ContainerCount);

            var receipt = new ReceiptCard(title: "Title",
                                          facts: new List <Fact>
            {
                new Fact("Место отправки", state.RouteFrom),
                new Fact("Место доставки", state.RouteTo),
                new Fact("Дата отправки", state.LoadingDate.ToString("dd MMM yyyy") + "г."),
                new Fact("Контейнеры", state.ContainerCount + " x 20 футов (30 тонн)")
            },
                                          total: price.ToString() + " р.",
                                          buttons: new List <CardAction>
            {
                new CardAction(ActionTypes.OpenUrl, title: "Перейти к оформлению", value: "https://isales.trcont.ru/"),
                new CardAction(ActionTypes.PostBack, title: "Сохранить расчет", value: "Save")
            }
                                          );

            var message = context.MakeMessage();

            message.Attachments.Add(receipt.ToAttachment());
            await context.PostAsync(message);

            context.Done(state);
        }
Пример #16
0
        private Attachment GetReceiptCard()
        {
            var order = this.ordersService.RetrieveOrder(this.order.OrderID);
            var creditCardOffuscated = order.PaymentDetails.CreditCardNumber.Substring(0, 4) + "-****";
            var receiptCard          = new ReceiptCard
            {
                Title = Resources.RootDialog_Receipt_Title,
                Facts = new List <Fact>
                {
                    new Fact(Resources.RootDialog_Receipt_OrderID, order.OrderID),
                    new Fact(Resources.RootDialog_Receipt_PaymentMethod, creditCardOffuscated)
                },
                Items = new List <ReceiptItem>
                {
                    new ReceiptItem(
                        title: order.FlowerCategoryName,
                        subtitle: order.Bouquet.Name,
                        price: order.Bouquet.Price.ToString("C"),
                        image: new CardImage(order.Bouquet.ImageUrl)),
                },
                Total = order.Bouquet.Price.ToString("C")
            };

            return(receiptCard.ToAttachment());
        }
Пример #17
0
        private async Task MessageReceivedAsync(IDialogContext context, IAwaitable <object> result)
        {
            var activity = await result;

            if (activity.ToString() == "Yes, Send a mail")
            {
                var OutputMessage = context.MakeMessage();
                var receiptCard   = new ReceiptCard
                {
                    Title = "Message Sent Sucessfully",
                    Facts = new List <Fact> {
                        new Fact("Sender", fromid), new Fact("Receiver", helpdesk), new Fact("Subject", subject)
                    },
                    Buttons = new List <CardAction>
                    {
                        new CardAction(
                            ActionTypes.OpenUrl,
                            "Open Account",
                            "https://www.outlook.com")
                    }
                };

                var attachment = receiptCard.ToAttachment();
                OutputMessage.Attachments.Add(attachment);
                await context.PostAsync(OutputMessage);
            }
            else
            {
                await context.PostAsync("MAIL NOT SENT ");
            }
            context.Done <object>(new object());
        }
        private Attachment GetReceiptCard()
        {
            var receiptCard = new ReceiptCard()
            {
                Title = "購物清單",
                Total = "256.0",
                Tax   = "1.0",
                Vat   = "5.0",
                Items = new List <ReceiptItem>()
                {
                    new ReceiptItem()
                    {
                        Title    = "美式咖啡",
                        Subtitle = "1杯",
                        Price    = "120.0",
                        Quantity = "1",
                        Image    = new CardImage("https://via.placeholder.com/150/e65100/FFFFFF/?text=C")
                    },
                    new ReceiptItem()
                    {
                        Title    = "全麥土司",
                        Subtitle = "2條",
                        Price    = "65.0",
                        Quantity = "2",
                        Image    = new CardImage("https://via.placeholder.com/150/fbc02d/FFFFFF/?text=T")
                    }
                },
                Facts = new List <Fact>()
                {
                    new Fact()
                    {
                        Key   = "日期",
                        Value = DateTime.Now.ToShortDateString()
                    },
                    new Fact()
                    {
                        Key   = "編號",
                        Value = "AB01234567"
                    },
                    new Fact()
                    {
                        Key   = "購買人",
                        Value = "Puck"
                    }
                },
                Buttons = new List <CardAction>()
                {
                    new CardAction()
                    {
                        Type  = ActionTypes.ImBack,
                        Title = "確認",
                        Value = "OK"
                    }
                }
            };

            return(receiptCard.ToAttachment());
        }
Пример #19
0
        public async Task getInformation(IDialogContext context, LuisResult result)
        {
            var message    = context.MakeMessage();
            var infoEntity = result.Entities.SingleOrDefault(e => e.Type == "College");

            System.Data.DataTable dtExcel;
            dtExcel           = new System.Data.DataTable();
            dtExcel.TableName = "MyExcelData";
            string           SourceConstr = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source='C:\\Users\\Sathya\\Pictures\\SCOUT-master\\Dialogs\\eamcetdataset.xlsx';Extended Properties= 'Excel 8.0;HDR=Yes;IMEX=1'";
            OleDbConnection  con          = new OleDbConnection(SourceConstr);
            string           query        = "Select * from [Sheet1$]";
            OleDbDataAdapter data         = new OleDbDataAdapter(query, con);

            data.Fill(dtExcel);

            string expression = "College = '" + infoEntity.Entity.ToUpper() + "'";

            DataRow[] foundRows;

            // Use the Select method to find all rows matching the filter.
            foundRows = dtExcel.Select(expression);

            //Print column 0 of each returned row.
            string res = "";



            var receiptCard = new ReceiptCard
            {
                Title   = infoEntity.Entity,
                Buttons = new List <CardAction>
                {
                    new CardAction(
                        ActionTypes.OpenUrl,
                        "Click Here")
                }
            };

            res = "To get further information about the college you can visit this website link" + " " + foundRows[0][19] + "     " + "<br />";
            CardAction plbutton = new CardAction()
            {
                Title = "Testing"
            };

            await context.PostAsync(res);

            context.Wait(MessageReceived);


            message.Attachments = new List <Attachment>();
            message.Attachments.Add(receiptCard.ToAttachment());

            await context.PostAsync(message);
        }
Пример #20
0
        public static async Task SetCart(IDialogContext context, TacoOrder order)
        {
            context.UserData.SetValue <bool>("InitialConversation", false);

            // Create header card.
            var reply = context.MakeMessage();

            var card = new CardAction();

            reply.Attachments = new List <Attachment>();

            List <CardAction> cardButtons = new List <CardAction>();
            List <CardImage>  cardImages  = new List <CardImage>();

            var items = new List <ReceiptItem>();

            // Find Matching Menu Item
            var selection = (int)order.TacoSelection;

            var menu             = new Services.InMemoryMenuRepository();
            var matchingMenuItem = menu.GetByID(selection);

            items.Add(new ReceiptItem()
            {
                Subtitle = matchingMenuItem.ItemDescription,
                Price    = matchingMenuItem.ItemPrice.ToString(),
                Quantity = order.Quantity.ToString(),
                Text     = matchingMenuItem.ItemDescription,
                Title    = matchingMenuItem.ItemName,
                Image    = new CardImage()
                {
                    Url = matchingMenuItem.ItemPicture
                }
            });

            var orderTotal = (matchingMenuItem.ItemPrice * order.Quantity);
            var tax        = (matchingMenuItem.ItemPrice * order.Quantity) * .07M;

            ReceiptCard plCard = new ReceiptCard()
            {
                Items = items,
                Tax   = tax.ToString("C"),
                Total = orderTotal.ToString("C"),
                Title = "Shopping Cart"
            };

            Attachment plAttachment = plCard.ToAttachment();

            reply.Attachments.Add(plAttachment);
            await context.PostAsync(reply);

            //context(order);
        }
Пример #21
0
        public static Attachment GetReceiptCard(string strTitle, List <ReceiptItem> lstItems, string strTotal, string strTax, string strVat)
        {
            ReceiptCard card = new ReceiptCard
            {
                Title = strTitle,
                Items = lstItems,
                Total = strTotal,
                Tax   = strTax,
                Vat   = strVat,
            };

            return(card.ToAttachment());
        }
Пример #22
0
        public static Attachment GetReceiptCard(string title, List <ReceiptItem> items, string total, string tax, string vat)
        {
            ReceiptCard card = new ReceiptCard
            {
                Title = title,
                Items = items,
                Tax   = tax,
                Total = total,
                Vat   = vat,
            };

            return(card.ToAttachment());
        }
Пример #23
0
        private static void ShowReceiptCard(IMessageActivity replyMessage)
        {
            List <CardImage> cardImages = new List <CardImage>();

            cardImages.Add(new CardImage(url: "http://lorempixel.com/200/200/food"));
            List <CardAction> cardButtons = new List <CardAction>();
            CardAction        plButton    = new CardAction()
            {
                Value = "https://en.wikipedia.org/wiki/Pig_Latin",
                Type  = "openUrl",
                Title = "Wikipedia Page"
            };

            cardButtons.Add(plButton);
            ReceiptItem lineItem1 = new ReceiptItem()
            {
                Title    = "Pork Shoulder",
                Subtitle = "8 lbs",
                Text     = null,
                Image    = new CardImage(url: "http://lorempixel.com/200/200/food"),
                Price    = "16.25",
                Quantity = "1",
                Tap      = null
            };
            ReceiptItem lineItem2 = new ReceiptItem()
            {
                Title    = "Bacon",
                Subtitle = "5 lbs",
                Text     = null,
                Image    = new CardImage(url: "http://lorempixel.com/200/200/food"),
                Price    = "34.50",
                Quantity = "2",
                Tap      = null
            };
            List <ReceiptItem> receiptList = new List <ReceiptItem>();

            receiptList.Add(lineItem1);
            receiptList.Add(lineItem2);
            ReceiptCard plCard = new ReceiptCard()
            {
                Title   = "I'm a receipt card, isn't this bacon expensive?",
                Buttons = cardButtons,
                Items   = receiptList,
                Total   = "275.25",
                Tax     = "27.52"
            };
            Attachment plAttachment = plCard.ToAttachment();

            replyMessage.Attachments.Add(plAttachment);
        }
Пример #24
0
        private async Task ShowCart(IDialogContext context)
        {
            // Create header card.
            var reply = context.MakeMessage();
            var card  = new CardAction();

            reply.Attachments = new List <Attachment>();
            List <CardAction> cardButtons = new List <CardAction>();
            List <CardImage>  cardImages  = new List <CardImage>();
            var     items      = new List <ReceiptItem>();
            var     menu       = new Services.InMemoryMenuRepository();
            decimal orderTotal = 0;

            foreach (var orderItem in this.order.Items)
            {
                // Find Matching Menu Item
                var selection        = (int)orderItem.TacoSelection;
                var matchingMenuItem = menu.GetByID(selection);
                orderTotal += (matchingMenuItem.ItemPrice * orderItem.Quantity);
                items.Add(new ReceiptItem()
                {
                    Subtitle = matchingMenuItem.ItemDescription,
                    Price    = (matchingMenuItem.ItemPrice * orderItem.Quantity).ToString("C"),
                    Quantity = orderItem.Quantity.ToString(),
                    Text     = matchingMenuItem.ItemDescription,
                    Title    = matchingMenuItem.ItemName,
                    Image    = new CardImage()
                    {
                        Url = matchingMenuItem.ItemPicture
                    }
                });
            }

            var tax = orderTotal * .07M;

            ReceiptCard plCard = new ReceiptCard()
            {
                Items = items,
                Tax   = tax.ToString("C"),
                Total = (orderTotal + tax).ToString("C"),
                Title = "Shopping Cart"
            };

            Attachment plAttachment = plCard.ToAttachment();

            reply.Attachments.Add(plAttachment);
            await context.PostAsync(reply);

            await this.StartOverAsync(context, "Your order has been submitted!");
        }
        private static Attachment GetReceiptCard(OrderForm order)
        {
            var receiptCard = new ReceiptCard
            {
                Title = "Mr/Mme " + order.Name,
                Facts = new List <Fact> {
                    new Fact("Commande No", "xxxxxxx"), new Fact("Méthode de paiement", "Carte")
                },
            };

            var receiptItems = new List <ReceiptItem>();

            int price = 0;

            double tax;

            switch (order.Size)
            {
            case SizeOptions.Petite:
                price = order.Type == TypeOptions.Classique? 5 : 7;
                break;

            case SizeOptions.Moyenne:
                price = order.Type == TypeOptions.Classique ? 7 : 9;
                break;

            case SizeOptions.Grande:
                price = order.Type == TypeOptions.Classique ? 9 : 11;
                break;
            }


            receiptItems.Add(new ReceiptItem("Poutine " + order.Type.ToString() + " " + order.Size.ToString(), price: price.ToString() + "$", quantity: "1"));

            if (order.Extras != null)
            {
                order.Extras.ForEach(x => {
                    receiptItems.Add(new ReceiptItem("Extra " + x.ToString(), price: "1$", quantity: "1"));
                });

                price = price + order.Extras.Count();
            }
            tax               = price * 0.15;
            receiptCard.Tax   = tax.ToString("###.##") + "$";
            receiptCard.Total = (price + tax).ToString("###.##") + "$";
            receiptCard.Items = receiptItems;


            return(receiptCard.ToAttachment());
        }
Пример #26
0
        public virtual async Task MessageReceivedAsync(IDialogContext context, IAwaitable <IMessageActivity> result)
        {
            if (!MemoryStorage.Orders.Any())
            {
                await context.PostAsync("Aún no has realizado ningún pedido");
            }
            else
            {
                var reply = context.MakeMessage();
                reply.Text             = "Estos son tus pedidos:";
                reply.AttachmentLayout = AttachmentLayoutTypes.Carousel;
                reply.Attachments      = new List <Attachment>();

                foreach (var order in MemoryStorage.Orders)
                {
                    List <CardAction> cardButtons = new List <CardAction>();

                    CardAction plButton = new CardAction()
                    {
                        Value = $"ver estado pedido número {order.Id}",
                        Type  = "postBack",
                        Title = "Detalle pedido"
                    };

                    cardButtons.Add(plButton);

                    ReceiptCard plCard = new ReceiptCard()
                    {
                        Title = $"Pedido nº {order.Id}",
                        Items = new List <ReceiptItem>()
                        {
                            new ReceiptItem()
                            {
                                Subtitle = order.Product
                            }
                        },
                        Total   = order.Price.ToString() + "€",
                        Buttons = cardButtons
                    };

                    Attachment plAttachment = plCard.ToAttachment();
                    reply.Attachments.Add(plAttachment);
                }

                await context.PostAsync(reply, CancellationToken.None);
            }

            context.Done(string.Empty);
        }
Пример #27
0
        private async Task <Attachment> GetReceiptCard(string orderNumber)
        {
            var order = await ordersApi.GetAsync(orderNumber);

            //check status of null
            if (order != null)
            {
                var orderStatus = "";
                switch (order.Status)
                {
                case "Open":
                    orderStatus = "🔷 OPEN. Estimated shipment date: " + order.EstimatedShipmentDate.Value.ToString("MM/dd/yyyy");
                    break;

                case "Invoiced":
                    orderStatus = "✔ INVOICED. Shipped on: " + order.ActualShipmentDate.Value.ToString("MM/dd/yyyy");
                    break;

                case "Waiting To Be Shipped":
                default:
                    orderStatus = "🔄 WAITING TO BE SHIPPED on: " + order.ActualShipmentDate.Value.ToString("MM/dd/yyyy");
                    break;
                }
                var receiptCard = new ReceiptCard
                {
                    Items = new List <ReceiptItem>
                    {
                        new ReceiptItem("Subtotal", price: order.Subtotal?.ToString()),
                        new ReceiptItem("Freight", price: order.Freight?.ToString()),
                        new ReceiptItem("Tax", price: order.Tax?.ToString())
                    },

                    Title = $"Order #{order.OrderNumber}",
                    Facts = new List <Fact> {
                        new Fact("Account #", order.AccountNumber.ToString()),
                        new Fact(orderStatus)
                    },

                    Total = order.Total.ToString()
                };

                return(receiptCard.ToAttachment());
            }
            else
            {
                return(null);
            }
        }
Пример #28
0
        private async Task ShowProfessionalProfile(IDialogContext context, IAwaitable <GetTokenResponse> tokenResponse)
        {
            try
            {
                var token = await tokenResponse;

                List <string> fields = new List <string>()
                {
                    LinkedInConstants.ProfileFields.POSITIONS,
                    LinkedInConstants.ProfileFields.SPECIALTIES
                };

                LinkedInProfile linkedinProfile = await(new LinkedInService().GetProfile(token.Token, fields));

                IMessageActivity professionalProfileMessage = context.MakeMessage();
                professionalProfileMessage.Attachments = new List <Attachment>();

                ReceiptCard professionalProfileCard = new ReceiptCard
                {
                    Title = linkedinProfile.FirstName + " " + linkedinProfile.LastName
                };

                if (null != linkedinProfile.Positions && 0 < linkedinProfile.Positions.Total)
                {
                    professionalProfileCard.Items = new List <ReceiptItem>();

                    linkedinProfile.Positions.Values.ForEach(x =>
                    {
                        professionalProfileCard.Items.Add(new ReceiptItem()
                        {
                            Title    = x.Title + " @ " + x.Company.Name,
                            Subtitle = x.Summary
                        });
                    });
                }

                professionalProfileMessage.Attachments.Add(professionalProfileCard.ToAttachment());

                await context.PostAsync(professionalProfileMessage);
            }
            catch (Exception exception)
            {
                await context.PostAsync(exception.Message);
            }
            ShowOptions(context);
        }
Пример #29
0
        private static async Task <Attachment> BuildReceiptCardAsync(PaymentRecord paymentRecord, string userId)
        {
            var shippingOption = await new ShippingService().GetShippingOptionAsync(paymentRecord.ShippingOption);

            var catalogItem = await new CatalogService().GetItemByIdAsync(paymentRecord.OrderId);

            var receiptItems = new List <ReceiptItem>();

            receiptItems.AddRange(paymentRecord.Items.Select <PaymentItem, ReceiptItem>(item =>
            {
                if (catalogItem.Title.Equals(item.Label))
                {
                    return(RootDialog.BuildReceiptItem(
                               catalogItem.Title,
                               catalogItem.Description,
                               $"{catalogItem.Currency} {catalogItem.Price.ToString("F")}",
                               catalogItem.ImageUrl));
                }
                else
                {
                    return(RootDialog.BuildReceiptItem(
                               item.Label,
                               null,
                               $"{item.Amount.Currency} {item.Amount.Value}",
                               null));
                }
            }));

            var receiptCard = new ReceiptCard
            {
                Title = Resources.RootDialog_Receipt_Title,
                Facts = new List <Fact>
                {
                    new Fact(Resources.RootDialog_Receipt_OrderID, paymentRecord.OrderId.ToString()),
                    new Fact(Resources.RootDialog_Receipt_PaymentMethod, paymentRecord.MethodName),
                    new Fact(Resources.RootDialog_Shipping_Address, paymentRecord.ShippingAddress.FullInline()),
                    new Fact(Resources.RootDialog_Shipping_Option, shippingOption != null ? shippingOption.Label : "N/A")
                },
                Items = receiptItems,
                Tax   = null, // Sales Tax is a displayed line item, leave this blank
                Total = $"{paymentRecord.Total.Amount.Currency} {paymentRecord.Total.Amount.Value}"
            };

            AddOrder(paymentRecord, userId);
            return(receiptCard.ToAttachment());
        }
Пример #30
0
            private Attachment GetReceiptCard()
            {
                var receiptCard = new ReceiptCard
                {
                    Title = Namestr,
                    Facts = new List <Fact> {
                        new Fact("Phone", Phonestr), new Fact("Date", DateOption), new Fact("Time", TimeOption + ":00")
                    },
                    Items = new List <ReceiptItem>
                    {
                        new ReceiptItem("Your rides", userchoice),
                    },
                    Total = "$" + totalprice.ToString(),
                };

                return(receiptCard.ToAttachment());
            }