private static List <BookReviewResult> GetBookReviews(string apiKey, string searchTerm) { var bookReviews = new List <BookReviewResult>(); var books = BooksAbstraction.GetBooks(apiKey, searchTerm); foreach (var book in books) { bookReviews.Add(new BookReviewResult { Book = book, Videos = VideosAbstraction.GetVideos(apiKey, book.Title) }); } return(bookReviews); }
public async Task <IActionResult> Get([FromServices] IConfiguration configuration, [FromQuery] GetBookReviewsRequest request) { string googleApiKey = configuration.GetSection("GoogleApiKey").Value; var bookReviews = new List <BookReviewResult>(); var books = BooksAbstraction.GetBooks(googleApiKey, request.Topic); foreach (var book in books) { bookReviews.Add(new BookReviewResult { Book = book, Videos = VideosAbstraction.GetVideos(googleApiKey, book.Title) }); } return(Ok(new { BookReviews = bookReviews })); }