public async Task <ActionResult <MinQuestion> > GetFitBQuestion(string BibleId, string BookName, int Chapter, int Verse)
        {
            BibleId = await QuizQuestion.GetValidBibleIdAsync(_context, BibleId);

            BibleBook Book = await BibleBook.GetBookAndChapterByNameAsync(_context, BibleId, BookName, Chapter);

            if (Book == null)
            {
                return(NotFound());
            }
            BibleVerse verse = new BibleVerse();

            try
            {
                verse = await _context.BibleVerses.Where(v => v.BibleId == BibleId &&
                                                         v.BookNumber == Book.BookNumber &&
                                                         v.Chapter == Chapter &&
                                                         v.Verse == Verse)
                        .SingleAsync();
            }
            catch
            {
                return(NotFound());
            }

            QuizQuestion Question = new QuizQuestion();

            Question = await Question.BuildQuestionForVerseAsync(_context, verse, 8, BibleId);

            Question.PopulatePBEQuestionInfo(Book);
            MinQuestion minQuestion = new MinQuestion(Question);

            return(minQuestion);
        }
Пример #2
0
        public async Task <ActionResult <IEnumerable <MinQuestion> > > GetQuizQuestions(string BibleId, string BookName, int Chapter)
        {
            BibleId = await QuizQuestion.GetValidBibleIdAsync(_context, BibleId);

            BibleBook Book = await BibleBook.GetBookAndChapterByNameAsync(_context, BibleId, BookName, Chapter);

            if (Book == null)
            {
                return(NotFound());
            }

            List <MinQuestion>  minQuestions = new List <MinQuestion>();
            List <QuizQuestion> Questions    = await _context.QuizQuestions
                                               .Include(Q => Q.QuizAnswers)
                                               .Where(Q => (Q.BibleId == BibleId || Q.BibleId == null) &&
                                                      Q.BookNumber == Book.BookNumber &&
                                                      Q.Chapter == Chapter &&
                                                      Q.IsDeleted == false &&
                                                      Q.IsAnswered == true).ToListAsync();

            foreach (QuizQuestion Question in Questions)
            {
                Question.PopulatePBEQuestionInfo(Book);
                MinQuestion minQuestion = new MinQuestion(Question);
                minQuestions.Add(minQuestion);
            }
            return(minQuestions);
        }