Exemplo n.º 1
0
        protected InputHandlerResult handleFavouriteLinks(
            UserSession us,
            string input)
        {
            if (ADD_TO_FAV.Equals(input.Trim().ToUpper()))
            {
                VerseSection vs = (VerseSection)us.getVariableObject("Browse.verse_section");
                if (vs == null)
                {
                    return new InputHandlerResult(
                             InputHandlerResult.UNDEFINED_MENU_ACTION,
                             InputHandlerResult.DEFAULT_MENU_ID,
                             InputHandlerResult.DEFAULT_PAGE_ID);
                }
                Verse start_verse = vs.start_verse;
                if (start_verse == null)
                {
                    return new InputHandlerResult(
                             InputHandlerResult.UNDEFINED_MENU_ACTION,
                             InputHandlerResult.DEFAULT_MENU_ID,
                             InputHandlerResult.DEFAULT_PAGE_ID);
                }
                Verse end_verse = vs.end_verse;
                if (us.favourite_verses.isFavouriteListFull())
                {
                    return new InputHandlerResult(
                                    "Your favourite list is full. Please first delete an existing favourite verse"); //invalid choice
                }
                int output = us.recordFavouriteSelection(start_verse, end_verse);
                if(output == FavouriteVerseManager.FAVOURITE_VERSE_ADDED_SUCCCESS)
                {
                    //end verse should never be null
                    String verse_ref = BibleHelper.getVerseSectionReferenceWithoutTranslation(start_verse, end_verse);
                    return new InputHandlerResult(
                                   InputHandlerResult.FAVOURITE_ADDED_ACTION,
                                   us.current_menu_loc,
                                   verse_ref + " has been added to your favourites"); //invalid choice
                }else if(output == FavouriteVerseManager.FAVOURITE_ALREADY_ADDED)
                {
                       return new InputHandlerResult(
                                   "This is already a favourite. You can't add duplicate favourites."); //invalid choice

                }
            }
            else if (SEND_TO_BUDDY.Equals(input.Trim().ToUpper()))
            {
                return new InputHandlerResult(
                             InputHandlerResult.NEW_MENU_ACTION,
                             MenuIDConstants.SEND_VERSE_MESSAGE_ID,
                             InputHandlerResult.DEFAULT_PAGE_ID);
            }
            else if (TAG_VERSE.Equals(input.Trim().ToUpper()))
            {
                return new InputHandlerResult(
                             InputHandlerResult.NEW_MENU_ACTION,
                             MenuIDConstants.TAG_VERSE_ID,
                             InputHandlerResult.DEFAULT_PAGE_ID);
            }
            else if (".".Equals(input.Trim().ToUpper()))
            {
                VerseSection vs = (VerseSection)us.getVariableObject("Browse.verse_section");
                if (vs == null)
                {
                    Console.WriteLine("Expected Browse.verse_section present, but not found");
                    return new InputHandlerResult(
                       InputHandlerResult.UNDEFINED_MENU_ACTION,
                       InputHandlerResult.DEFAULT_MENU_ID,
                       InputHandlerResult.DEFAULT_PAGE_ID);
                }
                String verse_ref = BibleHelper.getVerseSectionReferenceWithoutTranslation(vs.start_verse, vs.end_verse);
                return handleDirectVerseInput(us, verse_ref);
            }
            return new InputHandlerResult(
                         InputHandlerResult.UNDEFINED_MENU_ACTION,
                         InputHandlerResult.DEFAULT_MENU_ID,
                         InputHandlerResult.DEFAULT_PAGE_ID);
        }