Exemplo n.º 1
0
 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);
     }
 }
        /// <summary>
        /// Get Readong
        /// </summary>
        /// <param name="reading"></param>
        /// <param name="timeOfTheDay"></param>
        /// <param name="datetime"></param>
        /// <returns></returns>
        public Tuple <string, string> GetReading(string reading, int timeOfTheDay = 1, DateTime datetime = new DateTime())
        {
            switch (timeOfTheDay)
            {
            case 1:
                ReadingTitle = "1st - ";
                break;

            case 2:
                ReadingTitle = "2nd - ";
                break;

            default:
                ReadingTitle = "3rd - ";
                break;
            }
            if (!string.IsNullOrEmpty(reading))
            {
                var bookNameAndChapter = reading.Split('.');
                if (bookNameAndChapter[1].Contains("-"))
                {
                    var fromAndTo = bookNameAndChapter[1].Split('-');
                    ChapterFromAndTo = Tuple.Create(fromAndTo[0], fromAndTo[1]);
                }
                else
                {
                    ChapterFromAndTo = Tuple.Create(bookNameAndChapter[1], bookNameAndChapter[1]);
                }
                ReadingTitle += bookNameAndChapter[0];

                ReadingTitle += "\nChapter: " + bookNameAndChapter[1];

                var chapter = _dailyReadingRepository.SearchScriptures(bookNameAndChapter[0], Convert.ToInt16(ChapterFromAndTo.Item1), Convert.ToInt16(ChapterFromAndTo.Item1));
                ReadingContent = "";
                foreach (var verse in chapter.ChapterVerses)
                {
                    ReadingContent += string.Format("<p>{0}: {1} <p/>", verse.Id, verse.VerseText);
                }
            }
            return(Tuple.Create(ReadingTitle, ReadingContent));
        }