private async Task MessageReceivedAsync(IDialogContext context, IAwaitable <IMessageActivity> result) { var message = await result; IStockService nseService = new StockService(); var resp = await nseService.GetQuote(message.Text); if (resp.quoteResponse.result.Count < 1) { context.Done("Could not found the company you are looking for"); return; } var adaptiveCard = StockCards.GetStockCard(resp); var msg = context.MakeMessage(); msg.Attachments.Add(new Attachment() { Content = adaptiveCard, ContentType = AdaptiveCard.ContentType }); await context.PostAsync(msg); context.Done(""); }
private async Task MessageReceivedAsync(IDialogContext context) { try { IStockService nseService = new StockService(); var data = await nseService.GetIndexQuote(code); if (data.QuoteResponse.Result.Count == 0) { await context.PostAsync("Could not fetch values for selected Index"); context.Done("Could not fetch values for selected Index"); } var rich_msg = context.MakeMessage(); var adaptiveCard = StockCards.GetIndexCard(data); // adaptiveCard.Actions = new List<AdaptiveAction>() //{ // new AdaptiveSubmitAction() // { // Data = "Show Top Gainers", // Title = "Top Gainers" // }, // new AdaptiveSubmitAction() // { // Data = "Show Top Losers", // Title = "Top Losers" // }, // new AdaptiveSubmitAction() // { // Data = "Go back", // Title = "Go back" // } //}; rich_msg.Attachments.Add(new Attachment() { Content = adaptiveCard, ContentType = AdaptiveCard.ContentType }); await context.PostAsync(rich_msg); context.Wait(this.OnOptionSelected); } catch (Exception ex) { await context.PostAsync(ex.Message); context.Done(""); } }
private async Task ShowTopCharts(IDialogContext context, bool gainer) { try { await context.PostAsync("Preparing a chart"); var trend = gainer ? TrendType.Gainer : TrendType.Loser; var reply = context.MakeMessage(); IStockService stockService = new StockService(); var topCharts = gainer ? await stockService.GetTopGainers(bloomberg_code, "1D") : await stockService.GetTopLosers(bloomberg_code, "1D"); var adaptiveCard = StockCards.GetTopCharts(topCharts, trend); adaptiveCard.Actions = new List <AdaptiveAction>() { new AdaptiveSubmitAction() { Data = "Show Indices", Title = "Show Indices" }, new AdaptiveSubmitAction() { Data = "Go to main menu", Title = "Main Menu" } }; reply.Attachments.Add(new Attachment() { Content = adaptiveCard, ContentType = AdaptiveCard.ContentType }); await context.PostAsync(reply); context.Wait(this.OnMenuOptionSelectedAsync); } catch (Exception ex) { await context.PostAsync(ex.Message); context.Done(""); } }