public CountryManager(ICountryRepository repository, IPaginationUriService uriService) : base(repository, uriService)
 {
 }
        public static PaginationDataResult <T> CreatePaginationResult <T>(IReadOnlyList <T> pagedData, HttpStatusCode statusCode,
                                                                          PaginationQuery paginationQuery, int totalRecords, IPaginationUriService uriService)
        {
            var result     = new PaginationDataResult <T>(pagedData, statusCode, paginationQuery.PageNumber, paginationQuery.PageSize);
            var totalPages = Convert.ToInt32(Math.Ceiling((double)totalRecords / (double)paginationQuery.PageSize));

            result.NextPage = paginationQuery.PageNumber >= 1 && paginationQuery.PageNumber < totalPages
                ? uriService.GetPageUri(new PaginationQuery(paginationQuery.PageNumber + 1, paginationQuery.PageSize))
                : null;

            result.PreviousPage = paginationQuery.PageNumber - 1 >= 1 && paginationQuery.PageNumber <= totalPages
                ? uriService.GetPageUri(new PaginationQuery(paginationQuery.PageNumber - 1, paginationQuery.PageSize))
                : null;

            result.FirstPage    = uriService.GetPageUri(new PaginationQuery(1, paginationQuery.PageSize));
            result.LastPage     = uriService.GetPageUri(new PaginationQuery(totalPages, paginationQuery.PageSize));
            result.TotalPages   = totalPages;
            result.TotalRecords = totalRecords;

            return(result);
        }
示例#3
0
 public RegionManager(IRegionRepository repository, IPaginationUriService uriService) : base(repository, uriService)
 {
 }
 public ContinentalManager(IContinentalRepository repository, IPaginationUriService uriService) : base(repository, uriService)
 {
 }
 protected ManagerBase(IRepository <T, TKey> repository, IPaginationUriService uriService)
 {
     this.uriService = uriService;
     this.repository = repository;
 }