public async Task StartAsync(IDialogContext context)
        {
            try
            {
                _Sports = await TournamaticService.GetSports();

                if (_Sports.Count > 0)
                {
                    List <string> eras = new List <string>();
                    foreach (var era in _Sports)
                    {
                        eras.Add($"{era.Key}");
                    }
                    PromptDialog.Choice(context, AfterMenuSelection, eras, "Which sport are you interested in?");
                }
                else
                {
                    await context.PostAsync("I couldn't find any genres to show you");
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine($"Error when faceting by era: {e}");
                context.Done <object>(null);
            }
        }
Пример #2
0
        public virtual async Task MessageRecievedAsync(IDialogContext context, IAwaitable <IMessageActivity> result)
        {
            var message = await result;

            try
            {
                var tournaments = await TournamaticService.GetTournamentsByTitle(message.Text);

                if (tournaments.Count > 0)
                {
                    CardUtil.ShowHeroCard(message, tournaments);
                }
                else
                {
                    await context.PostAsync($"No tournaments that contains {message.Text} found");
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine($"Error when searching for tournaments: {e.Message}");
            }
            context.Done <object>(null);
        }
        private async Task AfterMenuSelection(IDialogContext context, IAwaitable <string> result)
        {
            var    optionSelected = await result;
            string selectedSport  = optionSelected.Split(' ')[0];

            try
            {
                var tournaments = await TournamaticService.GetTournamentsBySport(_Sports[selectedSport]);

                if (tournaments.Count > 0)
                {
                    CardUtil.ShowHeroCard((IMessageActivity)context.Activity, tournaments);
                }
                else
                {
                    await context.PostAsync($"I couldn't find any tournaments :0");
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine($"Error when filtering by sport: {e}");
            }
            context.Done <object>(null);
        }