/*this stores the last request and is responsible for maintaining synchronisation between memory * and DB views. */ public void saveVerseRequest( UserSession user_session, UserProfile user_profile, Verse start_verse, Verse end_verse) { DateTime dt = DateTime.Now; //update DB String verse_start_str = start_verse.getVerseReference(); String verse_end_str; if (end_verse == null) verse_end_str = "NULL"; else verse_end_str = end_verse.getVerseReference(); //now update in Memory View. VerseHistoryRecord vhr = new VerseHistoryRecord( -1, user_profile.id, user_session.session_id, dt, verse_start_str, verse_end_str); saveVerseRequestToDB( user_session, user_profile, start_verse, end_verse, dt, vhr); if (history_list.Count() < HISTORY_MAX_SIZE) { history_list.AddFirst(vhr); } else //this should correspond to the list HISTORY_MAX_SIZE size because it should never grow more than this { history_list.RemoveLast(); history_list.AddFirst(vhr); } }
/*this stores the bookmark and is responsible for maintaining synchronisation between memory * and DB views by also calling the save/update to db method. */ public int saveOrUpdateBookmark( UserSession user_session, UserProfile user_profile, Verse start_verse, Verse end_verse) { DateTime dt = DateTime.Now; //update DB String verse_start_str = start_verse.getVerseReference(); String verse_end_str; if (end_verse == null) verse_end_str = "NULL"; else verse_end_str = end_verse.getVerseReference(); //now update in Memory View. long b_id = -1; bool isNew = false; if (bookmark_verse != null) { b_id = bookmark_verse.id; } else { isNew = true; } bookmark_verse = new BookmarkVerseRecord( b_id, user_profile.id, user_session.session_id, dt, verse_start_str, verse_end_str); saveOrUpdateVerseRequestToDB( user_session, user_profile, start_verse, end_verse, dt, bookmark_verse, isNew); return 0; }
/*the start and end for now cant span more than one book*/ public static String getVerseSectionReferenceWithoutTranslation(Verse start_verse, Verse end_verse) { string section = ""; if (start_verse != null) { section = start_verse.book.name + " " + start_verse.chapter.chapter_id + ":" + start_verse.verse_id; if (end_verse == null || (end_verse != null && start_verse.getVerseReference() == end_verse.getVerseReference())) { //dont do anything } else if (start_verse.chapter == end_verse.chapter) { section += "-" + end_verse.verse_id; } else if (start_verse.chapter != end_verse.chapter) { section += "-" + end_verse.chapter.chapter_id + ":" + end_verse.verse_id; } } return section; }