async void OnScan_Clicked(object sender, EventArgs eventArgs)
        {
            try
            {
                ZXing.Mobile.MobileBarcodeScanner scanner = new ZXing.Mobile.MobileBarcodeScanner();
                scanner.Torch(true);
                ZXing.Result result = await scanner.Scan();

                if (result != null)
                {
                    Console.WriteLine("Scanned Barcode: " + result.Text);

                    GoogleBooksService service = new GoogleBooksService();
                    Book bookResult            = await service.GetBookAsync(result.Text);

                    if (bookResult == null)
                    {
                        await DisplayAlert("Could not find Book", "Could not find book. Please check the barcode and try again.", "OK");
                    }
                    else
                    {
                        this._book.Book = bookResult;
                    }
                }
            }
            catch (Exception ex)
            {
                await DisplayAlert("Error Occured", "An Error occured while scanning. Try again later.", "Ok");

                Log.Warning("Scanner", ex.Message);
                throw new Exception(ex.Message, ex);
            }
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            var authService = new GoogleAuthService();

            var auth = authService.Login().GetAwaiter().GetResult();
            //authService.RefreshToken(auth).GetAwaiter().GetResult();

            var livros = new GoogleBooksService().PesquisarLivros("Use a cabeça!");

            foreach (var item in livros)
            {
            }

            Console.ReadKey();
        }
		public BookFinderController(IHttpClientFactory clientFactory)
		{
			googleBooks = new GoogleBooksService(clientFactory);
		}