示例#1
0
 public AuthorDetail(AuthorRepository authorRepository)
 {
     this.Id   = authorRepository.Id;
     this.Name = authorRepository.Name;
     if (authorRepository.Books != null)
     {
         this.Books = BookItem.MapRepo(authorRepository.Books);
     }
 }
示例#2
0
        public ApiResponse Index([FromQuery] Query query, [FromHeader] Header header)
        {
            if (query.Pagination)
            {
                List <BookRepository> booksRepo = this.bookApplication.GetList(query.Search, query.Page, query.PerPage);
                int             count           = this.bookApplication.Count(query.Search);
                decimal         pageInCount     = ((decimal)count) / query.PerPage;
                PaginationModel paginate        = new PaginationModel()
                {
                    TotalPage = (int)Math.Ceiling(pageInCount),
                    Page      = query.Page,
                    PerPage   = query.PerPage,
                    Data      = BookItem.MapRepo(booksRepo),
                    Total     = count
                };

                return(new ApiResponsePagination(HttpStatusCode.OK, paginate));
            }
            else
            {
                var booksRepo = this.bookApplication.GetList(query.Search, query.Page, query.PerPage);
                return(new ApiResponseDataList(HttpStatusCode.OK, booksRepo, booksRepo.Count));
            }
        }