예제 #1
0
        public BookController(ILoanManager loanManager, IBookManager bookManager)
        {
            LoanManager = loanManager;
            BookManager = bookManager;

            GoogleBookSearch = new GoogleBookSearch();
        }
예제 #2
0
        public void TestExists()
        {
            //arrange
            GoogleBookSearch testSearch = new GoogleBookSearch();

            //assert
            Assert.IsNotNull(testSearch);
        }
예제 #3
0
        // GET: api/Search
        public async Task <IEnumerable <Book> > GetBooks(string search) //GeneralSearch not implemented yet. To be added later.
        {
            GoogleBookSearch getBooksSearch = new GoogleBookSearch();
            // return getBooksSearch.GeneralSearch(search).Result;
            //cheking identifier
            var TheResult = await getBooksSearch.GeneralSearch(search);

            return(TheResult);
        }
        public IActionResult SearchBooks(string searchText)
        {
            //if the book is not found in database search in google books
            GoogleBookSearch books = new GoogleBookSearch("Paluga", "AIzaSyBd8Wo7uTz1_CNPSk_W0SAgy_Y5h8u10bQ");

            var results = books.Search(searchText);

            return(Ok(new { SearchText = searchText, ISBN = "123456", Title = "Business Adventures" }));
        }
        public void GoogleBookSearchTest()
        {
            var googleBookSearch = new GoogleBookSearch();

            var response = googleBookSearch.Search("9780672321436", SearchType.ISBN);

            var result = response.items.Any();

            Assert.IsNotNull(result);
        }
예제 #6
0
        public void TestGoogleBookSearch()
        {
            string[] searchTerms = new string[] { "Harry Potter", "Spongebob", "Herr der Ringe" };
            ObservableCollection <Book> books = null;

            foreach (var item in searchTerms)
            {
                books = GoogleBookSearch.SearchBooks(item).GetAwaiter().GetResult();
                Assert.AreEqual(10, books.Count);
            }

            books = GoogleBookSearch.SearchBooks("asdasdadasdadaa").GetAwaiter().GetResult();
            Assert.AreEqual(0, books.Count);
        }
        public async Task <IActionResult> SearchBooks(string searchText)
        {
            //scope = https://www.googleapis.com/auth/books
            //if the book is not found in database search in google books
            GoogleBookSearch books = new GoogleBookSearch("Paluga", "AIzaSyBd8Wo7uTz1_CNPSk_W0SAgy_Y5h8u10bQ");

            //  var results = await books.Search(searchText);

            //9781760553128
            var results = await books.SearchISBN(searchText);

            return(Respond(results));
            //return Ok(new { SearchText = searchText, ISBN = "9781760553128", Title = "Google Book story" });
        }
예제 #8
0
        public void testTitleSearchReturns()
        {
            //arrange
            GoogleBookSearch testSearch = new GoogleBookSearch();

            //act
            IEnumerable <Models.Book> result = testSearch.TitleSearch("The Shining").Result;

            //assert
            Assert.IsNotNull(result);
            var book = result.FirstOrDefault(n => n.Title.Equals("The Shining"));

            Assert.IsNotNull(book);
        }
예제 #9
0
        public void testSearchById()
        {
            //arrange
            GoogleBookSearch testSearch = new GoogleBookSearch();

            //act
            IEnumerable <Models.Book> result = testSearch.GeneralSearch("8_DfMSS9r9cC").Result;

            //assert
            Assert.IsNotNull(result);
            var CarrieResult = result.FirstOrDefault(n => n.Title.Equals("Diversity and Evolutionary Biology of Tropical Flowers"));

            Assert.IsNotNull(CarrieResult);
        }
예제 #10
0
        public void testValidAuthorName()
        {
            //arrange
            GoogleBookSearch testSearch = new GoogleBookSearch();

            //act
            IEnumerable <Models.Book> result = testSearch.GeneralSearch("Stephen King").Result;

            //assert
            Assert.IsNotNull(result);
            var CarrieResult = result.FirstOrDefault(n => n.Title.Equals("Carrie"));

            Assert.IsNotNull(CarrieResult);
        }
예제 #11
0
        public void testTitleSearchReturnsNothing()
        {
            //arrange
            GoogleBookSearch testSearch = new GoogleBookSearch();

            //act
            Guid   guid       = Guid.NewGuid();
            String GuidString = guid.ToString();
            IEnumerable <Models.Book> result = testSearch.TitleSearch(GuidString).Result;

            //assert
            var GuidResult = result.Any(n => n.Title.Equals(GuidString));

            Assert.IsFalse(GuidResult);
        }
예제 #12
0
        public void testISBNeSearchReturns()
        {
            //arrange
            GoogleBookSearch testSearch = new GoogleBookSearch();

            //act
            IEnumerable <Models.Book> result = testSearch.ISBNSearch("1741147514").Result;

            //assert
            Assert.IsNotNull(result);
            var book = result.FirstOrDefault(n => n.Title.Equals("The Book of Everything"));

            Assert.IsNotNull(book);
            Assert.AreEqual("The Book of Everything", book.Title);
        }
        public BookSearchViewModel()
        {
            SearchCommand = new DelegateCommand(async p =>
            {
                //Buchsuche
                _searchTriggered?.Invoke(this, EventArgs.Empty);
                Books = await GoogleBookSearch.SearchBooks(SearchTerm);
            },
                                                p =>
                                                //Wann kann die Suche angestoßen werden?
                                                !string.IsNullOrWhiteSpace(SearchTerm)
                                                );

            BookSelectedCommand = new DelegateCommand(p =>
            {
                if (p is Book book)
                {
                    //TODO: ViewModel bauen
                    TodoViewModel model = new TodoViewModel(book);
                    ServicesHelper.NavigationService.Navigate(Interfaces.NavigationTarget.TodoItems, model);
                }
            });
        }
예제 #14
0
        public async Task <IHttpActionResult> PostBookshelfItem(BookshelfItem bookshelfItem)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (bookshelfItem.ImgURI == null)
            {
                GoogleBookSearch   search = new GoogleBookSearch();
                IEnumerable <Book> result = await search.GeneralSearch(bookshelfItem.ISBN);


                Book firstResult = result.FirstOrDefault();
                if (firstResult != null)
                {
                    bookshelfItem.ImgURI = firstResult.ImgURI;
                }
            }
            //if uri null go get if
            //call uri returner
            //bookshelfItem
            //web api 401 error if not logged in



            var             userID        = User.Identity.GetUserId();
            string          currentUserID = User.Identity.GetUserId();
            ApplicationUser userFound     = db.Users.Find(currentUserID);

            bookshelfItem.User = userFound;
            db.BookShelfItems.Add(bookshelfItem);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = bookshelfItem.Id }, bookshelfItem));
        }
예제 #15
0
 public LoanManager(IBookRepository bookRepository, IRepository<Loan> loanRepository, GoogleBookSearch googleBookSearch)
 {
     LoanRepository = loanRepository;
     BookRepository = bookRepository;
     GoogleBookSearch = googleBookSearch;
 }