Ejemplo n.º 1
0
        public BookList()
        {
            InitializeComponent();

            using (BookQuestions context = new BookQuestions())
            {
                IEnumerable<Book> books = context.Books.ToList();
                this.ListBoxBooks.ItemsSource = books;
            }
        }
Ejemplo n.º 2
0
        public Questions(int bookId)
        {
            InitializeComponent();
            using (BookQuestions context = new BookQuestions())
            {
                Book searchedBook = context.Books
                    .Include("Questions")
                    .Include("Questions.Answers")
                    .FirstOrDefault(b => b.Id == bookId);
                this.book = searchedBook;
                this.questions = searchedBook.Questions.ToList();
            }

            this.labelBookName.Content = this.book.Name;
            this.labelQuestionName.Content = this.book.Questions.ToList()[0].Name;
            this.answersList.ItemsSource = this.questions.FirstOrDefault().Answers;
            this.selectedQuestionIndex = 0;
            this.labelCurrentOf.Content = $"Question {selectedQuestionIndex + 1} of {this.questions.Count}";
        }