Esempio n. 1
0
        async private void ButtonSearch_Click(object sender, RoutedEventArgs e)
        {
            IEnumerable <IBook> Books = null;

            ButtonSearch.IsEnabled = false; // I dont want reentrancy
            try
            {
                Books = await Service.GetBooksAsync(TextBoxSearchString.Text);
            }
            catch (BookServiceException BSEx)
            {
                ErrorDialog(BSEx.ErrorText);
            }

            // Put all found books in list view
            _FoundBooks.Clear();
            if (Books != null)
            {
                foreach (IBook B in Books)
                {
                    _FoundBooks.Add(B);
                }
            }
            ButtonSearch.IsEnabled = true;
        }
Esempio n. 2
0
        public async System.Threading.Tasks.Task <ActionResult> Index(string searchString)
        {
            List <Book> allStock = new List <Book>();

            //Session Cookies
            if (Session["Stock"] != null)
            {
                allStock = Session["Stock"] as List <Book>;
                // Keeping the search with each session
                if (!string.IsNullOrEmpty(searchString))
                {
                    allStock = allStock.Where(B => B.Title.ToLower().Contains(searchString) || B.Author.ToLower().Contains(searchString)).ToList();
                }
            }
            else
            {
                BookstoreService   bService = new BookstoreService();
                IEnumerable <Book> allBooks = await bService.GetBooksAsync(searchString);

                allStock = allBooks.ToList();

                Session["Stock"] = allStock;
            }

            return(View(allStock));
        }
Esempio n. 3
0
        // Get books from bookstore and search string
        public async Task <ActionResult> BooksAsync()
        {
            var bookstoreService = new BookstoreService();

            ViewBag.Books = await bookstoreService.GetBooksAsync(Request.Form["searchString"]);

            return(View("Index"));
        }
Esempio n. 4
0
 public void RandomSearchstrings()
 {
     for (int i = 0; i < 1000; i++)
     {
         byte[] searchStringByteArray = new byte[2048];
         rand.NextBytes(searchStringByteArray);
         string searchString = System.Text.Encoding.UTF8.GetString(searchStringByteArray);
         var    task         = service.GetBooksAsync(searchString);
         task.Start();
         task.Wait(1000);
         Assert.IsTrue(task.IsCompleted);
     }
 }
Esempio n. 5
0
 public async Task <IEnumerable <IBookDTO> > GetBooksFromService(string keyword = null)
 {
     return(await bookstoreService.GetBooksAsync(keyword));
 }
Esempio n. 6
0
        // GET: Book
        public async Task <ActionResult> Index()
        {
            IEnumerable <BookDTO> books = await bookstoreService.GetBooksAsync() as IEnumerable <BookDTO>;

            return(View(books));
        }