private async Task ShowSessionsHeroCard(IDialogContext context)
{
var replyToConversation = context.MakeMessage();
replyToConversation.AttachmentLayout = AttachmentLayoutTypes.Carousel;
replyToConversation.Attachments = await GetSessionHeroCard(context);
//replyToConversation.Attachments.Add(GetSessionHeroCard());
await context.PostAsync(replyToConversation);
}
private async Task<List<Attachment>> GetSessionHeroCard(IDialogContext context)
{
List<Attachment> list = new List<Attachment>();
List<CardAction> cardButtons = new List<CardAction>();
foreach (var sessionDetails in scheduleList)
{
string[] session = GetSplittedDetails(sessionDetails);
hospitalName = session[0]; //Hospital Name: {0}
availableDay = session[1]; //Available Day: {1}
appointmentNo = session[2]; // Appoinment No: {2}
sessionAvailable = session[3]; // Session: {3}
HeroCard hero = new HeroCard()
{
Title = hospitalName,
Subtitle = availableDay,
Text = sessionAvailable + appointmentNo,
Buttons = cardButtons
};
list.Add(hero.ToAttachment());
}
CardAction getSessionValues = new CardAction()
{
Value = hospitalName + availableDay + sessionAvailable + appointmentNo,
Type = ActionTypes.ImBack,
Title = " Select Appointment "
};
cardButtons.Add(getSessionValues);
string selectedAppointment = getSessionValues.Value.ToString();
await GetSelectedAppointment(context, selectedAppointment);
return list;
}
private async Task GetSelectedAppointment(IDialogContext context, string sessionSelected)
{
var replyToConversation = context.MakeMessage();
//replyToConversation.AttachmentLayout = AttachmentLayoutTypes.List;
string[] result = Utility.SplitSelectedApoitmentString(sessionSelected);
var heroCard = new HeroCard()
{
Title = "Appointment Schedule",
Subtitle = "These are the Appointment Details",
Text = "Hospital selected : " + result[0] + "\n" + "Day of Appointment : " + result[1] + "\n" + "Time of Appointment : " + result[2] + "\n" + "Appointment Number" + result[3],
}.ToAttachment();
Attachment attachment = new Attachment()
{
Content = heroCard.Content,
ContentType = heroCard.ContentType
};
replyToConversation.Attachments.Add(attachment);
await context.PostAsync(replyToConversation);
}
-
我是否正确定义了按钮?
-
CardAction getSessionValues甚至在我单击之前就获得了一些值
在按钮上。如何避免这种情况。
-
我想不出这里出了什么问题,请帮忙。(我肯定我做的事情很愚蠢。)
提前感谢:)