Skip to content

Instantly share code, notes, and snippets.

@dgkanatsios
Last active October 30, 2016 16:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dgkanatsios/8731c5db23cb2fcac6c6383a90be965d to your computer and use it in GitHub Desktop.
Save dgkanatsios/8731c5db23cb2fcac6c6383a90be965d to your computer and use it in GitHub Desktop.
private async Task ProcessFinished(IDialogContext ctx, IAwaitable<bool> confirmation)
{
bool userConfirmed = await confirmation;
if (userConfirmed == false)
{
ctx.Done("finished");
return;
}
result = await
ReserveTravelUtility.ReserveTravelAsync(selectedEmail, selectedName, selectedLicensePlate,
selectedParkingLocationDetails.Name, selectedParkingLot.parkingLotID, arrivalDateTime, departureDateTime,
selectedParkingLot.Price, selectedParkingLot.PricelistId);
if (result.Success)
{
var response = result.Result;
var imessageactivity = ctx.MakeMessage();
var messageactivity = imessageactivity as Activity;
var replyToConversation = messageactivity;
replyToConversation.Type = "message";
replyToConversation.Recipient = messageactivity.From;
List<CardImage> cardImages = new List<CardImage>();
cardImages.Add(new CardImage(url: selectedParkingLot.Image));
ReceiptItem lineItem = new ReceiptItem()
{
Title = result.Result.Booking.ParkingLotOperator,
Subtitle = result.Result.Booking.ParkingLotAddress,
Text = result.Result.Booking.Email,
Image = new CardImage(url: selectedParkingLot.Image),
Price = result.Result.Booking.PriceNumber.ToString(),
Quantity = "1",
Tap = null
};
List<ReceiptItem> receiptList = new List<ReceiptItem>();
receiptList.Add(lineItem);
//https://developers.facebook.com/docs/messenger-platform/send-api-reference/receipt-template
ReceiptCard plCard = new ReceiptCard()
{
Title = "I'm a receipt card",
Items = receiptList,
Total = result.Result.Booking.PriceNumber.ToString(),
Tax = "0",
Facts = new List<Fact>(){
new Fact("payment_method","Cash"),
new Fact("currency","EUR"),
new Fact("total_tax","01"),
new Fact("address:street_1", selectedEmail),
new Fact("order_number",result.Result.Booking.Code.ToString()),
new Fact("currency","EUR"),
new Fact("order_url",result.Message ?? "http://www.parkaround.gr/")},
};
var msg=ctx.MakeMessage();
Attachment plAttachment = plCard.ToAttachment();
replyToConversation.Attachments = new List<Attachment>();
replyToConversation.Attachments.Add(plAttachment);
replyToConversation.Recipient.Name = msg.Recipient.Name;
await ctx.PostAsync(StringMessages.ConfirmedReservation);
await ctx.PostAsync(replyToConversation);
}
else
{
await ctx.PostAsync(result.Message);
}
ctx.Done("Finished");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment