Example #1
0
        private void RecommendationMenuActions(UserSession userSession, Message message)
        {
            var userId  = userSession.SessionOwnerId;
            var command = message.Text;

            if (EnumExtension.TryParseEnumByDescription <Category, GenreData>(command, out Category selectedCategory))
            {
                userSession.SetSelectedCategory(selectedCategory);
                SendMessageToUser(userId, ResponsePhrases.SelectGenre, BotKeyboardsSchemes.GetGenreSelectionKeyboard(selectedCategory));
                userSession.SetDialogLayout(DialogLayout.GenreSelection);
            }
            else if (command.EqualsBotCommand(BotCommands.Back))
            {
                HelloActions(userSession, message);
            }
            else if (command.EqualsBotCommand(BotCommands.Rate))
            {
                RatingActions(userSession, message);
            }
            else
            {
                SendMessageToUser(userId, ResponsePhrases.RecommendationsMenuMessage, BotKeyboardsSchemes.RecommendationsMenu);
                userSession.SetDialogLayout(DialogLayout.RecommendationsMenu);
            }
        }
Example #2
0
        private async void GiveRecommendation <T>(UserSession userSession, Message message, Func <string, Task <RecommendationData> > recommender) where T : struct
        {
            var command = userSession.SelectedGenreApiString ?? message.Text;

            if (EnumExtension.TryParseEnumByDescription <T, GenreData>(command, out T genre))
            {
                userSession.SetSelectedGenreApiString(genre.GetEnumCustomAttribute <T, GenreData>().ApiString);
                await SendRecommendation(recommender, userSession,
                                         ResponsePhrases.RecommendationMessage + userSession.SelectedCategory.GetEnumCustomAttribute <Category, GenreData>().Description.ToLower(),
                                         userSession.SelectedGenreApiString);
            }
            else
            {
                await SendMessageToUser(userSession.SessionOwnerId, ResponsePhrases.SelectGenre, BotKeyboardsSchemes.GetGenreSelectionKeyboard(userSession.SelectedCategory));
            }
        }