public async Task <IActionResult> GetQuestions(int id)
        {
            var questions = await _context.Set <Question>().Where(x => x.ChapterId == id).ToListAsync();

            questions.Add(new Question());
            return(Ok(questions));
        }
        public async Task <IActionResult> GenerateTest([FromBody] TestGeneration testGeneration)
        {
            var questions = await _context.Set <Question>().Include(x => x.Chapter)
                            .Where(x => testGeneration.SelectedChapters.Contains(x.ChapterId.Value))
                            .GroupBy(x => x.Chapter.Title).Select(x => new Test()
            {
                Theme     = x.Key,
                Questions = x.Select(y => new TestQuestion()
                {
                    Text = y.Text, Content = y.Content
                }).ToArray()
            }).ToArrayAsync();

            var tests = new List <Test>();

            foreach (var question in questions)
            {
                tests.Add(Generate(question, testGeneration.Percentage));
            }

            var serialized = JsonConvert.SerializeObject(tests, Formatting.Indented);

            using (var f = System.IO.File.CreateText("test.json"))
            {
                await f.WriteAsync(serialized);
            }
            return(Ok(tests));
        }
        public async Task <IActionResult> GetBooks()
        {
            var books = await _context.Set <Book>().ToArrayAsync();

            return(Ok(books));
        }