private Activity CreateReceipt(Activity message) { Activity replyToConversation = message.CreateReply("Receipt card"); replyToConversation.Recipient = message.From; replyToConversation.Type = "message"; replyToConversation.Attachments = new List<Attachment>(); List<CardImage> cardImages = new List<CardImage>(); cardImages.Add(new CardImage(url: "https://<ImageUrl1>")); 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: "https://<ImageUrl1>"), Price = "16.25", Quantity = "1", Tap = null }; ReceiptItem lineItem2 = new ReceiptItem() { Title = "Bacon", Subtitle = "5 lbs", Text = null, Image = new CardImage(url: "https://<ImageUrl2>"), 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(); replyToConversation.Attachments.Add(plAttachment); return replyToConversation; }
/// <summary> /// Creates a new attachment from <see cref="ReceiptCard"/>. /// </summary> /// <param name="card"> The instance of <see cref="ReceiptCard"/>.</param> /// <returns> The generated attachment.</returns> public static Attachment ToAttachment(this ReceiptCard card) { return(new Attachment { Content = card, ContentType = ReceiptCard.ContentType }); }
/// <summary> /// Creates a new attachment from <see cref="ReceiptCard"/>. /// </summary> /// <param name="card"> The instance of <see cref="ReceiptCard"/>.</param> /// <returns> The generated attachment.</returns> public static Attachment ToAttachment(this ReceiptCard card) { return(CreateAttachment(card, ReceiptCard.ContentType)); }