示例#1
0
        public ActionResult NewBookSearchResults(NewBookSearchViewModel input)
        {
            GoogleBooksSearchResponse response = GoogleBooksAPIHandler.FullSearch(new Models.MiscModels.Search {
                inauthor = input.InAuthor, intitle = input.InTitle, isbn = input.ISBN, other = input.Other, subject = input.Subject
            });
            NewBookViewModel viewModel = new NewBookViewModel {
                Books = Utilities.GoogleBookSearchUtilities.ParseSearchResponse(response), ClubId = input.ClubId
            };

            return(View(viewModel));
        }
        public static List <Book> ParseSearchResponse(GoogleBooksSearchResponse response)
        {
            List <Book> output = new List <Book>();

            if (response.items != null)
            {
                foreach (Item item in response.items)
                {
                    output.Add(ParseSearchItem(item));
                }
            }
            return(output);
        }
示例#3
0
        private List <List <Book> > GetBooksByAuthor(List <Author> authors)
        {
            List <List <Book> > AuthorBooks            = new List <List <Book> >();
            List <GoogleBooksSearchResponse> responses = new List <GoogleBooksSearchResponse>();

            Parallel.ForEach(authors, (author) =>
            {
                GoogleBooksSearchResponse response = GoogleBooksAPIHandler.FullSearch(new Search {
                    inauthor = author.Name
                });
                responses.Add(response);
            });
            foreach (GoogleBooksSearchResponse response in responses)
            {
                AuthorBooks.Add(Utilities.GoogleBookSearchUtilities.ParseSearchResponse(response).ToList());
            }
            AuthorBooks = AuthorBooks.OrderByDescending(l => l.Count).ToList();
            return(AuthorBooks);
        }
示例#4
0
        public ActionResult SearchResults(Search search)
        {
            GoogleBooksSearchResponse response = GoogleBooksAPIHandler.FullSearch(search);

            return(View(Utilities.GoogleBookSearchUtilities.ParseSearchResponse(response)));
        }
示例#5
0
        public ActionResult NavBarSearchResults(string input)
        {
            GoogleBooksSearchResponse response = GoogleBooksAPIHandler.NavBarSearch(input);

            return(View("NavBarSearchResults", Utilities.GoogleBookSearchUtilities.ParseSearchResponse(response)));
        }