Esempio n. 1
0
        public async Task <JsonResult> SearchBooksAsync(string searchQuery, [FromServices] IBooksClient booksClient)
        {
            var results = await booksClient.SearchBooksAsync(searchQuery);

            List <BookSearchResultViewModel> models = new List <BookSearchResultViewModel>();

            foreach (var result in results)
            {
                BookSearchResultViewModel model = new BookSearchResultViewModel();

                model.Title         = result.Title;
                model.Description   = result.Description;
                model.CoverImageUrl = result.CoverImageUrl;
                model.Rating        = result.Rating == null ? null : result.Rating.ToString();
                model.RatingCount   = result.RatingCount.ToString();
                model.PublishedDate = result.PublishedDate == null ? null : result.PublishedDate.ToString();
                model.PageCount     = result.PageCount == null ? null : result.PageCount.ToString();
                model.Isbn          = result.Isbn;

                if (result.Authors != null)
                {
                    model.Authors = string.Join(", ", result.Authors);
                }

                if (result.Genres != null)
                {
                    model.Genres = string.Join(", ", result.Genres);
                }

                if (result.PublishedDate != null)
                {
                    model.Year = result.PublishedDate.Value.Year.ToString();
                }

                models.Add(model);
            }

            return(Json(models));
        }
 public GenreController(IGenresClient genresClient, IBooksClient booksClient)
 {
     this.booksClient  = booksClient;
     this.genresClient = genresClient;
 }
Esempio n. 3
0
 public BooksController(IBooksClient booksClient, IMapper mapper)
 {
     _booksClient = booksClient;
     _mapper      = mapper;
 }
Esempio n. 4
0
 public HomeController(IBooksClient booksClient)
 {
     this.booksClient = booksClient;
 }
 public BooksClientsTests()
 {
     BooksClient = Helper.GetClient().Books;
 }
Esempio n. 6
0
 public ValuesController(IBooksClient booksClient)
 {
     _booksClient = booksClient;
 }
 public BooksClientsTests()
 {
     BooksClient = Helper.GetClient().Books;
 }
 public CartController(ICartItemClient cartItemClient, ICartsClient cartsClient, IBooksClient booksClient)
 {
     this.cartsClient    = cartsClient;
     this.booksClient    = booksClient;
     this.cartItemClient = cartItemClient;
 }
Esempio n. 9
0
 public BookPageController(IBooksClient booksClient)
 {
     this.booksClient = booksClient;
 }