public static AdaptiveCard GetCard(OutputStack OutputStack) { var mainCard = new AdaptiveCard(new AdaptiveSchemaVersion(1, 0)); if (OutputStack.Data != null && OutputStack.Data._cognigy != null && OutputStack.Data._cognigy._default != null && OutputStack.Data._cognigy._default._buttons != null) { string btnText = OutputStack.Data._cognigy._default._buttons.text;//to get buttons text mainCard.Body.Add(AdaptiveCardHelper.AddTextBlock(btnText)); if (OutputStack.Data._cognigy._default._buttons.buttons != null && OutputStack.Data._cognigy._default._buttons.buttons.Count() > 0) //if (OutputStack.Data._cognigy._default._buttons.buttons != null && OutputStack.Data._cognigy._default._buttons.buttons.Count() > 0) { int i = 1; foreach (var button in OutputStack.Data._cognigy._default._buttons.buttons) { //string btnId = Guid.NewGuid().ToString(); string btnId = "btn"; btnId = btnId + Convert.ToString(i); var dataJson = @"{""Type"":"" " + button.title + @" "",""Entered"":""test123""}"; mainCard.Actions.Add(AdaptiveCardHelper.AddButtonToAdaptiveCard(btnId, button, dataJson)); i = i + 1; } return(mainCard); } } return(null); }
public static AdaptiveCard HolidayListAdaptiveCard(List <string> date, List <string> description) { var card = new AdaptiveCard(new AdaptiveSchemaVersion(1, 0)); List <AdaptiveColumn> columns = new List <AdaptiveColumn>(); AdaptiveColumn column = AdaptiveCardHelper.AddAdaptiveColumn(); AdaptiveColumn column1 = AdaptiveCardHelper.AddAdaptiveColumn(); AdaptiveColumn column2 = AdaptiveCardHelper.AddAdaptiveColumn(); AdaptiveCardHelper.AddItemToAdaptiveColumn(column, AdaptiveCardHelper.AddTextBlock("Sr. No", AdaptiveTextWeight.Bolder, AdaptiveTextSize.Large, AdaptiveTextColor.Accent)); AdaptiveCardHelper.AddItemToAdaptiveColumn(column1, AdaptiveCardHelper.AddTextBlock("Date", AdaptiveTextWeight.Bolder, AdaptiveTextSize.Large, AdaptiveTextColor.Good)); AdaptiveCardHelper.AddItemToAdaptiveColumn(column2, AdaptiveCardHelper.AddTextBlock("Description", AdaptiveTextWeight.Bolder, AdaptiveTextSize.Large, AdaptiveTextColor.Dark)); for (int i = 0; i < date.Count; i++) { AdaptiveCardHelper.AddItemToAdaptiveColumn(column, AdaptiveCardHelper.AddTextBlock((i + 1).ToString())); AdaptiveCardHelper.AddItemToAdaptiveColumn(column1, AdaptiveCardHelper.AddTextBlock((date[i]).ToString())); AdaptiveCardHelper.AddItemToAdaptiveColumn(column2, AdaptiveCardHelper.AddTextBlock((description[i]).ToString())); } var columnSet = new AdaptiveColumnSet(); columnSet.Columns.Add(column); columnSet.Columns.Add(column1); columnSet.Columns.Add(column2); var container = new AdaptiveContainer(); container.Style = AdaptiveContainerStyle.Emphasis; container.Items.Add(columnSet); card.Body.Add(container); return(card); }