private void GetCommentaryUrl(Document document, out string url, out string caption) { int chapterNumber = document.GetStoredValue <Commentary>(x => x.ChapterNumber); int verseNumber = document.GetStoredValue <Commentary>(x => x.FirstVerseNumber); string commentatorCode = document.GetStoredValue <Commentary>(x => x.CommentatorCode); CommentatorRepository.TryGet(commentatorCode, out Commentator commentator); string commentatorDescription = commentator?.Description; url = $"/Tafsir/{commentatorCode}/{chapterNumber}.{verseNumber}"; caption = $"Commentary by {commentatorDescription} for {chapterNumber}.{verseNumber}"; }
public ActionResult Index(string commentatorCode, int chapterNumber, int verseNumber) { if (!CommentatorRepository.TryGet(commentatorCode, out Commentator commentator)) { return(HttpNotFound()); } Commentary commentary = CommentaryRepository.GetForVerse( commentatorCode: commentatorCode, chapterNumber: chapterNumber, verseNumber: verseNumber); if (commentary == null) { commentary = new Commentary( commentatorCode: commentatorCode, chapterNumber: chapterNumber, firstVerseNumber: verseNumber, lastVerseNumber: verseNumber, text: new[] { new TextContent("No tafsir found for this verse", false) }); } var commentatorAndCommentary = new CommentatorAndCommentary( commentator: commentator, commentary: commentary); string url = $"/Tafsir/{commentatorCode}/"; var selectChapterAndVerse = SelectChapterAndVerseFactory.CreateForCommentary( commentatorCode: commentatorCode, selectedChapterNumber: chapterNumber, selectedVerseNumber: verseNumber, url: url); var viewModel = new ViewModel( commentatorAndCommentary: commentatorAndCommentary, selectChapterAndVerse: selectChapterAndVerse); return(View("VerseCommentary", viewModel)); }