private static IEnumerable <VerseRangeReference> AddSurroundingVerses(int?context, VerseRangeReference firstReference) { IEnumerable <VerseRangeReference> verseRangeReferences; int numberOfVerses = QuranStructure.Chapter(firstReference.Chapter).NumberOfVerses; int firstVerse = Math.Max(1, firstReference.FirstVerse - context.Value); int lastVerse = Math.Min(numberOfVerses, firstReference.LastVerse + context.Value); var newVerseReference = new VerseRangeReference( chapter: firstReference.Chapter, firstVerse: firstVerse, lastVerse: lastVerse); verseRangeReferences = new[] { newVerseReference }; return(verseRangeReferences); }
public ActionResult Index(string commentatorCode, int chapterNumber, int verseNumber) { if (!QuranStructure.TryValidateChapterAndVerse(chapterNumber, verseNumber)) { return(HttpNotFound()); } CommentariesForVerse viewModel = CommentariesForVerseBuilder.Create( commentatorCode: commentatorCode, chapterNumber: chapterNumber, verseNumber: verseNumber); return(View("CommentariesForVerse", viewModel)); }
public ActionResult Index(int chapterNumber, int verseNumber) { if (!QuranStructure.TryValidateChapterAndVerse(chapterNumber, verseNumber)) { return(HttpNotFound()); } Chapter chapter = ChapterRepository.Get(chapterNumber); var verseReference = new VerseReference(chapterNumber, verseNumber); IEnumerable <Persistence.Models.Hadith> hadiths = HadithRepository.GetForVerse(verseReference) .OrderBy(x => x.References[0]); IEnumerable <HadithViewModel> hadithViewModels = HadithViewModelFactory.Create(hadiths); var viewModel = new ViewModel( chapter: chapter, verseNumber: verseNumber, hadiths: hadithViewModels); return(View("VerseHadiths", viewModel)); }
public ActionResult Index(int chapterNumber, int verseNumber) { if (!QuranStructure.TryValidateChapterAndVerse(chapterNumber, verseNumber)) { return(HttpNotFound()); } Chapter chapter = ChapterRepository.Get(chapterNumber); VerseAnalysis analysis = VerseAnalysisRepository.GetForVerse(chapterNumber, verseNumber); var selectChapterAndVerse = new SelectChapterAndVerse( selectedChapterNumber: chapterNumber, selectedVerseNumber: verseNumber, url: "/Analysis/"); var viewModel = new ViewModel( chapter: chapter, verseNumber: verseNumber, verseAnalysis: analysis, selectChapterAndVerse: selectChapterAndVerse); return(View("VerseAnalysis", viewModel)); }
public Chapter Get(int chapterNumber) => QuranStructure.Chapter(chapterNumber);