private async Task LoadBooks(BooksSearchRequest searchRequest = null) { var entities = await _booksService.Get <List <Model.Models.Book> >(searchRequest); booksDataGridView.AutoGenerateColumns = false; booksDataGridView.DataSource = entities; }
private async void SearchBooksBtn_Click(object sender, System.EventArgs e) { var searchRequest = new BooksSearchRequest() { IsAuthorsLoadingEnabled = true, IsGenresLoadingEnabled = true, SearchTerm = bookSearchTermTextBox.Text.Trim() }; var genreIdObj = bookGenresComboBox.SelectedValue; if (int.TryParse(genreIdObj.ToString(), out int genreId)) { searchRequest.GenreId = genreId; } var authorIdObj = bookAuthorsComboBox.SelectedValue; if (int.TryParse(authorIdObj.ToString(), out int authorId)) { searchRequest.AuthorId = authorId; } await LoadBooks(searchRequest); }
private async void BooksForm_Load(object sender, System.EventArgs e) { await LoadAuthors(); await LoadGenres(); var searchRequest = new BooksSearchRequest() { IsGenresLoadingEnabled = true, IsAuthorsLoadingEnabled = true }; await LoadBooks(searchRequest); }
public async Task Init() { if (Genres.Count == 0) { var genreEntities = await _genresService.Get <List <Model.Models.Genre> >(null); genreEntities.ForEach((genre) => Genres.Add(genre)); } if (Authors.Count == 0) { var authorsEntities = await _authorsService.Get <List <Model.Models.Author> >(null); authorsEntities.ForEach((author) => Authors.Add(author)); } var searchRequest = new BooksSearchRequest() { IsAuthorsLoadingEnabled = true, IsGenresLoadingEnabled = true }; if (SelectedGenre != null) { searchRequest.GenreId = SelectedGenre.Id; } if (SelectedAuthor != null) { searchRequest.AuthorId = SelectedAuthor.Id; } if (!string.IsNullOrEmpty(SearchTerm)) { searchRequest.SearchTerm = SearchTerm.Trim(); } var bookEntities = await _booksService.Get <List <Model.Models.Book> >(searchRequest); Books.Clear(); bookEntities.ForEach((book) => Books.Add(book)); }