public BookList() { InitializeComponent(); using (BookQuestions context = new BookQuestions()) { IEnumerable<Book> books = context.Books.ToList(); this.ListBoxBooks.ItemsSource = books; } }
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}"; }