Beispiel #1
0
        public static async Task <IList <BibleBook> > GetPBEBooksAsync(BiblePathsCoreDbContext context, string BibleId)
        {
            IList <BibleBook> PBEBooks = await context.BibleBooks
                                         .Include(B => B.BibleChapters)
                                         .Where(B => B.BibleId == BibleId)
                                         .ToListAsync();

            // Querying for Question counts for each Book/Chapter gets expensive let's grab all of them
            // and pass them around for counting.
            List <QuizQuestion> Questions = await context.QuizQuestions
                                            .Where(Q => (Q.BibleId == BibleId || Q.BibleId == null) &&
                                                   Q.IsDeleted == false)
                                            .ToListAsync();

            // TODO: This is not ideal, we should be simply be deleting rather than soft deleting these
            //       So that a simple ANY would work vs. having to retrieve all of these.
            List <QuizBookList> BookLists = await context.QuizBookLists
                                            .Include(L => L.QuizBookListBookMaps)
                                            .Where(L => L.IsDeleted == false)
                                            .ToListAsync();

            foreach (BibleBook Book in PBEBooks)
            {
                await Book.AddPBEBookPropertiesAsync(context, null, Questions, BookLists);
            }
            return(PBEBooks);
        }