Beispiel #1
0
        public IActionResult GetWithPagination([FromQuery] PagingParams pagingParams, [FromQuery] SearchTransaction search, [FromQuery] FilterObject filterObject)
        {
            search.CustomerId = Guid.Parse(AppClaim.CustomerId);
            var transaction = transactionService.GetAll(pagingParams, search, filterObject);

            if (transaction != null)
            {
                Response.Headers.Add("X-Pagination", transaction.GetHeader().ToJson());

                var request = _httpContextAccessor.HttpContext.Request;

                var response = new PaginationResponseModel <AccountTransactionDto>
                {
                    Paging   = transaction.GetHeader(),
                    Links    = PaginationResponseModel <AccountTransactionDto> .GetLinks(transaction, request),
                    Lists    = transaction.List,
                    TotalSum = transaction.TotaSum
                };

                return(Ok(response));
            }
            else
            {
                return(NotFound());
            }
        }
Beispiel #2
0
        /// <summary>
        /// Ok the specified paged list
        /// </summary>
        /// <typeparam name="T">The Entity</typeparam>
        /// <param name="list">The list.</param>
        /// <param name="hasNextPage">if set to <c>true</c> [has next page].</param>
        /// <param name="totalCount">The total count.</param>
        /// <returns>the value</returns>
        protected IActionResult Ok <T>(IList <T> list, bool hasNextPage, int totalCount) where T : class
        {
            var model = new PaginationResponseModel <T>()
            {
                Meta = new PaginationInformationModel {
                    Count = list.Count, HasNextPage = hasNextPage, TotalCount = totalCount
                },
                Results = list
            };

            return(this.StatusCode(200, model));
        }
        public async Task <IActionResult> GetAll([FromQuery] int pageSize = 10, [FromQuery] int pageIndex = 0, [FromQuery] string ids = null)
        {
            if (!string.IsNullOrEmpty(ids))
            {
                return(await GetItemsByIds(ids));
            }

            var totalItems = _storeViynlRepository.GetAll().Result.LongCount();

            var itemsOnPage = _storeViynlRepository.GetAll().Result
                              .OrderBy(c => c.Title)
                              .Paginate(pageIndex, pageSize);

            var model = new PaginationResponseModel <StoreVinylListResponseModel>(
                pageIndex, pageSize, totalItems, _autoMapper.Map <IEnumerable <StoreVinylListResponseModel> >(itemsOnPage));

            return(Ok(model));
        }
Beispiel #4
0
        public async Task <IActionResult> GetByReferencesId(int?genreId, [FromQuery] int pageSize = 10, [FromQuery] int pageIndex = 0)
        {
            if (!genreId.HasValue)
            {
                return(NotFound());
            }

            var results = await _storeViynlRepository.Find(_ => _.GenreId == genreId);

            var totalItems = results
                             .LongCount();

            var itemsOnPage = results.AsEnumerable()
                              .Paginate(pageIndex, pageSize);

            var model = new PaginationResponseModel <StoreVinylListResponseModel>(
                pageIndex, pageSize, totalItems, _autoMapper.Map <IEnumerable <StoreVinylListResponseModel> >(itemsOnPage));

            return(Ok(model));
        }
 public ResultsPaginationResponseModel()
 {
     Pagination = new PaginationResponseModel();
 }