Ejemplo n.º 1
0
        public CommentariesForVerse Create(string commentatorCode, int chapterNumber, int verseNumber)
        {
            Dictionary <string, Commentator> commentatorByCode =
                CommentatorRepository.GetAll()
                .ToDictionary(x => x.Code, StringComparer.InvariantCultureIgnoreCase);

            Chapter chapter = ChapterRepository.Get(chapterNumber);
            IEnumerable <Commentary> commentaries;

            if (string.IsNullOrEmpty(commentatorCode))
            {
                commentaries = CommentaryRepository.GetForVerse(chapterNumber, verseNumber);
            }
            else
            {
                commentaries = new Commentary[]
                {
                    CommentaryRepository.GetForVerse(commentatorCode, chapterNumber, verseNumber)
                }
                .Where(x => x != null);
            }

            IEnumerable <CommentatorAndCommentary> commentatorsAndCommentaries =
                commentaries
                .OrderBy(x => x.CommentatorCode)
                .Select(
                    x => new CommentatorAndCommentary(
                        commentator: commentatorByCode[x.CommentatorCode],
                        commentary: x)
                    );

            var selectChapterAndVerse = new SelectChapterAndVerse(
                selectedChapterNumber: chapterNumber,
                selectedVerseNumber: verseNumber,
                url: "/Tafsirs");
            var viewModel = new CommentariesForVerse(
                chapter: chapter,
                verseNumber: verseNumber,
                selectChapterAndVerse: selectChapterAndVerse,
                commentaries: commentatorsAndCommentaries);

            return(viewModel);
        }
Ejemplo n.º 2
0
        private IEnumerable <SelectListItem> CreateTafsirsSelection(string selectedValue)
        {
            var group = new SelectListGroup {
                Name = SearchContextGroupNames.Commentaries
            };
            var result = new List <SelectListItem>();
            IEnumerable <Commentator> commentators =
                CommentatorRepository.GetAll()
                .OrderBy(x => x.Code);

            foreach (Commentator commentator in commentators)
            {
                string code = $"{SearchContexts.Commentaries}-{commentator.Code}";
                var    item = new SelectListItem {
                    Group    = group,
                    Selected = (selectedValue == code),
                    Value    = code,
                    Text     = $"{commentator.Code} ({commentator.Description})"
                };
                result.Add(item);
            }
            return(result);
        }
Ejemplo n.º 3
0
        public ActionResult Index()
        {
            var viewModel = CommentatorRepository.GetAll();

            return(View("Commentators", viewModel));
        }