public void AddBook() { bool result = _navigationService.GetWindow <BookDetailsViewModel>().ShowWindowModal(); if (result) { //Adding a new books to list Book newBook = null; using (var dbService = _dbServiceManager.GetService()) { var books = dbService.Books.GetAll(); foreach (var b in books.OrderByDescending(cli => cli.Id)) { if (AllBooks.Any(book => book.Id == b.Id)) { break; } else { if (newBook == null) { newBook = b; } AllBooks.Add(b); } } } Books = new BindableCollection <Book>(AllBooks); SelectedBook = newBook; } }