public Bible GetBible(BibleConstants.BibleVersions bibleVersion = BibleConstants.BibleVersions.Msg, string bibleFullName = "The Message Bible") { var selectedBible = SessionBible?.Find(x => x.ShortName.Equals(bibleVersion.ToString(), StringComparison.CurrentCultureIgnoreCase)); if (selectedBible != null) { return(selectedBible); } var bibleFilepath = HostingEnvironment.MapPath($"~/App_Data/Books/{bibleVersion}.json"); var bibleStreamToString = File.ReadAllText(bibleFilepath); selectedBible = BibleParser(bibleStreamToString); if (SessionBible != null) { SessionBible.Add(selectedBible); } else { SessionBible = new List <Bible> { selectedBible }; } return(selectedBible); }
/// <summary> /// Bible Index /// </summary> /// <param name="translation"></param> /// <returns></returns> // GET: /Administrator/ BibleReading/ public ActionResult Index(BibleConstants.BibleVersions translation = BibleConstants.BibleVersions.Msg) { BibleContent = _bibleRepository.GetBible(translation); ViewBag.BibleContent = BibleContent; return(View()); }
public Bible GetBible(BibleConstants.BibleVersions bibleVersion = BibleConstants.BibleVersions.Tmsg, string bibleFullName = "The Message Bible") { if (SessionBible != null) { return(SessionBible); } var bibleFilepath = HostingEnvironment.MapPath(string.Format("~/App_Data/Books/{0}", "MSG.json.txt")).ToString(); var bibleStreamToString = File.ReadAllText(bibleFilepath); return(SessionBible = BibleParser(bibleStreamToString, bibleFullName, null, bibleVersion)); }
public JsonResult SelectTranslation(int chapterId = 1, int bookId = 1, BibleConstants.BibleVersions bibleVersion = BibleConstants.BibleVersions.Msg) { var bible = _bibleRepository.GetBible(bibleVersion); var book = bible.Books.Find(x => x.Id == bookId); var chapter = book?.BookChapter.FirstOrDefault(x => x.ChapterId == chapterId); var readingContent = chapter?.ChapterVerses.Aggregate("", (current, verse) => current + $"<p>{verse.Id}: {verse.VerseText} <p/>"); var readingTitle = book?.BookName + " \nChapter: " + chapter?.ChapterId; return(Json(new { readingTitle, chapterId, bookId, translation = bible.Name, shortName = bible.ShortName, readingContent, status = true }, JsonRequestBehavior.AllowGet)); }
public IEnumerable <Chapter> SearchScripturesByChapters(string bookName, int chapterFrom = 1, int chapterTo = 1, BibleConstants.BibleVersions bibleVersion = BibleConstants.BibleVersions.Msg) { var bible = GetBible(); var chapterList = new List <Chapter>(); var dailyBook = new Book(); foreach (var book in bible.Books.Where(book => book.BookName.ToLower().StartsWith(bookName.Trim().ToLower()))) { dailyBook = book; break; } foreach (var chapter in dailyBook.BookChapter) { if (chapter.ChapterId == chapterFrom || chapter.ChapterId == chapterTo) { chapterList.Add(chapter); } } return(chapterList); }
public Chapter SearchScriptures(string bookName, int chapterNumber = 1, int verse = 1, int from = 1, int to = 1, BibleConstants.BibleVersions bibleVersion = BibleConstants.BibleVersions.Msg) { var bible = GetBible(); var dailyBook = new Book(); foreach (var book in bible.Books.Where(book => book.BookName.ToLower().StartsWith(bookName.Trim().ToLower()))) { dailyBook = book; break; } var dailyChapter = new Chapter(); foreach (var chapter in dailyBook.BookChapter.Where(chapter => chapter.ChapterId == chapterNumber)) { dailyChapter = chapter; break; } return(dailyChapter); }
public Chapter SearchScriptures(int bookId, int chapterNumber = 1, int verse = 1, int from = 1, int to = 1, BibleConstants.BibleVersions bibleVersion = BibleConstants.BibleVersions.Msg) { var bible = GetBible(); var dailyChapter = new Chapter(); var dailyBook = new Book(); foreach (var book in bible.Books.Where(book => book.Id == bookId)) { dailyBook = book; break; } foreach (var chapter in dailyBook.BookChapter.Where(chapter => chapter.ChapterId == chapterNumber)) { dailyChapter = chapter; break; } return(dailyChapter); }
public IHttpActionResult Get(int bookId, int chapterNumber = 1, int verse = 1, int from = 1, int to = 1, BibleConstants.BibleVersions bibleVersion = BibleConstants.BibleVersions.Msg) { try { var result = _bibleRepository.SearchScriptures(bookId, chapterNumber, verse, from, to, bibleVersion); return(Ok(result)); } catch (Exception exception) { throw new InvalidOperationException("Unable to fetch bible passage", exception); } }
public Bible BibleParser(string theEntireBibleJsonString, string bibleName = "Unknown", string shortName = "Unknown", BibleConstants.BibleVersions bibleVersion = BibleConstants.BibleVersions.Tmsg) { var tempBible = new Bible { Books = new List <Book>(), Name = bibleName, ShortName = shortName, Version = bibleVersion.ToString() }; //All books after reading from File var bibleBooks = JsonConvert.DeserializeObject <Bible>(theEntireBibleJsonString); //Each Book in the Bible tempBible.Books = bibleBooks.Books.OrderBy(x => x.Id).ToList(); return(tempBible); }
public JsonResult GotoNextPrevious(int chapterId = 1, int bookId = 1, string direction = "", BibleConstants.BibleVersions bibleVersion = BibleConstants.BibleVersions.Msg) { var bible = _bibleRepository.GetBible(bibleVersion); if (direction == "previous") { if (chapterId == 1 && bookId != 1) { bookId--; var gotoLastChapter = bible.Books.Last(x => x.Id == bookId); chapterId = gotoLastChapter.BookChapter.Last().ChapterId; } else { if (bookId == 1) { bookId = 66; var gotoLastChapter = bible.Books.Last(x => x.Id == bookId); chapterId = gotoLastChapter.BookChapter.Last().ChapterId; } else { chapterId--; } } } else { var checkLastChapterReached = bible.Books.FirstOrDefault(x => x.Id == bookId); if (checkLastChapterReached != null && chapterId == checkLastChapterReached.BookChapter.Last().ChapterId) { if (bookId == 66) { bookId = 1; } else { bookId++; } chapterId = 1; } else { chapterId++; } } var book = bible.Books.FirstOrDefault(x => x.Id == bookId); var chapter = book?.BookChapter.FirstOrDefault(x => x.ChapterId == chapterId); var readingContent = chapter?.ChapterVerses.Aggregate("", (current, verse) => current + $"<p>{verse.Id}: {verse.VerseText} <p/>"); var readingTitle = book?.BookName + " \nChapter: " + chapter?.ChapterId; return(Json(new { readingTitle, chapterId, bookId, readingContent, status = true }, JsonRequestBehavior.AllowGet)); }