public MinChapter(BibleChapter Chapter)
 {
     BibleId       = Chapter.BibleId;
     BookNumber    = Chapter.BookNumber;
     Name          = Chapter.Name;
     ChapterNumber = Chapter.ChapterNumber;
     Verses        = Chapter.Verses ?? 0;
 }
示例#2
0
        public async Task <bool> AddPBEBookPropertiesAsync(BiblePathsCoreDbContext context, int?ChapterNum, List <QuizQuestion> Questions, List <QuizBookList> BookLists)
        {
            if (Questions == null)
            {
                Questions = await context.QuizQuestions
                            .Where(Q => (Q.BibleId == BibleId || Q.BibleId == null) &&
                                   Q.BookNumber == BookNumber &&
                                   Q.IsDeleted == false)
                            .ToListAsync();
            }
            InBookList    = IsInBooklist(context, BookLists);
            QuestionCount = GetQuestionCount(Questions);
            HasChallenge  = HasChallengedQuestion(Questions);
            HasCommentary = await HasCommentaryAsync(context);

            if (HasCommentary)
            {
                CommentaryTitle = await GetCommentaryTitleAsync(context);

                CommentaryQuestionCount = GetCommentaryQuestionCount(Questions);
                CommentaryHasChallenge  = CommentaryHasChallengedQuestion(Questions);
            }
            if (ChapterNum.HasValue)
            {
                if (ChapterNum != Bible.CommentaryChapter)
                {
                    BibleChapter Chapter = await context.BibleChapters
                                           .Where(C => C.BibleId == BibleId && C.BookNumber == BookNumber && C.ChapterNumber == ChapterNum)
                                           .SingleAsync();

                    Chapter.AddPBEChapterProperties(Questions);
                    this.BibleChapters.Add(Chapter);
                }
            }
            else
            {
                // Caller must have loaded Chapters
                foreach (BibleChapter Chapter in BibleChapters)
                {
                    Chapter.AddPBEChapterProperties(Questions);
                }
            }
            return(true);
        }