public async void SearchAsync()
        {
            StartSearch  = true;
            SearchResult = null;
            CanLoadMore  = false;
            _searchQuery = Query;
            _busyIndicatorManager.Start();

            List <BookSearchResult> items;

            try
            {
                items = await _bookSearch.Search(_book, _searchQuery, LOAD_COUNT);
            }
            catch (SearchInBookInterruptedException)
            {
                //skip search an interrupted exception (it has occurred after FAS), search will be repeated at OnActivate
                return;
            }
            finally
            {
                _busyIndicatorManager.Stop();
            }

            SearchResult = new BindableCollection <SearchInBookResultItemDataModel>(
                items.Select(result => _searchController.ToDataModel(result, _searchQuery, BookId)));

            CanLoadMore = items.Count >= LOAD_COUNT;
        }
        protected override async void GetBookmarksAsync()
        {
            _busyIndicatorManager.Start();

            var bookmarks = await Task <IEnumerable <BookmarkModel> > .Factory.StartNew(() => _bookmarkRepository.GetBookmarks());

            var books = await Task <IEnumerable <BookModel> > .Factory.StartNew(() => _bookRepository.GetAll());

            var bookmarksWithBooks = Enumerable.Join(bookmarks, books, bm => bm.BookID, b => b.BookID,
                                                     (bookmark, book) => new { Bookmark = bookmark, Book = book });

            Bookmarks = new BindableCollection <BookmarkItemDataModel>(bookmarksWithBooks
                                                                       .Select(b => _bookmarksController.CreateBookmarkDataModel(b.Bookmark, b.Book != null ? b.Book.Title : null)));

            _busyIndicatorManager.Stop();
        }
        public async void SearchAsync()
        {
            _busyIndicatorManager.Start();
            try
            {
                SearchResult = null;
                await InitBookmarks();

                SearchResult = await Task <List <BookmarkSearchResultDaraModel> > .Factory.StartNew(() => _bookmarks
                                                                                                    .Where(b => b.BookmarkText.IndexOf(Query, StringComparison.InvariantCultureIgnoreCase) > -1)
                                                                                                    .Select(b =>
                {
                    b.SearchQuery = Query;
                    return(b);
                })
                                                                                                    .ToList());
            }
            finally
            {
                _busyIndicatorManager.Stop();
            }
        }
Ejemplo n.º 4
0
        protected override async void GetBookmarksAsync()
        {
            _busyIndicatorManager.Start();

            var book = await Task <BookModel> .Factory.StartNew(() => _bookRepository.Get(BookId, false));

            if (book != null)
            {
                EmptyContent = string.Format("{0} \"{1}\"", UIStrings.BookmarksPivot_ThisBook_EmptyList, book.Title);
            }
            else
            {
                EmptyContent = UIStrings.BookmarksPivot_ThisBook_EmptyList;
            }

            var bookmarks =
                await Task <IEnumerable <BookmarkModel> > .Factory.StartNew(() => _bookmarkService.GetBookmarks(BookId));

            Bookmarks = new BindableCollection <BookmarkItemDataModel>(bookmarks
                                                                       .Select(bm => _bookmarksController.CreateBookmarkDataModel(bm)));

            _busyIndicatorManager.Stop();
        }