/// <summary>
        /// Updates books.
        /// </summary>
        public virtual async void UpdateBooks()
        {
            ConnectionErrorOccured = false;
            Loaded = false;

            try
            {
                var books = await App.CurrentApplication.BookRequestManager.GetBooksByCategory(this.BooksCategory, 10, 0);

                if (books != null)
                {
                    foreach (Book book in books)
                    {
                        BookViewModel bookViewModel = new BookViewModel(book);
                        bookViewModel.CheckCoverExistence();
                        this.Books.Add(bookViewModel);
                    }
                }

            }
            catch (WebException webEx)
            {
                ConnectionErrorOccured = true;
            }
            finally
            {
                Loaded = true;
            }

        }
Example #2
0
        /// <summary>
        /// Loads more #number_of_results results. Method is called, when user reached last item in list.
        /// </summary>
        public virtual async void FetchMoreBooks()
        {
            var resultsCount = App.CurrentApplication.ResultsCount;
            if (Books.Count % resultsCount == 0) // true, if it is possible to load more books
            {
                try
                {
                    ConnectionErrorOccured = false;
                    Loaded = false;

                    var books = await App.CurrentApplication.BookRequestManager.SearchBooks(title, author, (uint)resultsCount, (uint)Books.Count);

                    if (books != null)
                    {
                        foreach (Book book in books)
                        {
                            BookViewModel bookViewModel = new BookViewModel(book);
                            bookViewModel.CheckCoverExistence();
                            this.Books.Add(bookViewModel);
                        }
                    }
                }
                catch (WebException webEx)
                {
                    //App.CurrentApplication.MessageService.ShowErrorMessage("Server is down.", "Error");
                    ConnectionErrorOccured = true;
                }
                finally
                {
                    Loaded = true;
                }
            }
        }