Ejemplo n.º 1
0
        // ObjectResult<PagedList<Book>>
        public async Task <ObjectResult> GetBooks(string Nickname, int?page, int?size)
        {
            _logger.LogInformation($"Get reader {Nickname} books information");
            var response = await readerService.GetReaderBooks(Nickname);

            if (response == null)
            {
                _logger.LogInformation("Internal gateway error");
                return(StatusCode(500, "Internal error"));
            }

            var books = new List <Book>();

            if (response.Code == 200)
            {
                var nameList = response.Value;
                foreach (var bookName in nameList)
                {
                    var bookresponse = await bookService.GetBook(bookName);

                    if (bookresponse != null && bookresponse.Code == 200)
                    {
                        books.Add(bookresponse.Value);
                    }
                }
                return(GetPagedList(books, page, size));
            }
            return(StatusCode(response.Code, response.Message));
        }