public IActionResult GetRefundRequests(RefundResourceParameters resourceParameters) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var refundsRequests = _usersRepository.GetRefundRequests(resourceParameters); var prevLink = refundsRequests.HasPrevious ? _resourceUriHelper.CreateResourceUri(resourceParameters, ResourceUriType.PrevoiusPage, nameof(GetRefundRequests)) : null; var nextLink = refundsRequests.HasNext ? _resourceUriHelper.CreateResourceUri(resourceParameters, ResourceUriType.NextPage, nameof(GetRefundRequests)) : null; Response.Headers.Add("X-Pagination", Helpers.PaginationMetadata.GeneratePaginationMetadata(refundsRequests, resourceParameters, prevLink, nextLink)); var refundDtos = new List <RefundRequestDto>(); foreach (var r in refundsRequests) { refundDtos.Add(Mapper.Map <RefundRequestDto>(r)); } return(Ok(refundDtos)); }
public PagedList <RefundRequest> GetRefundRequests(RefundResourceParameters resourceParameters) { IQueryable <RefundRequest> beforePaging = _dataContext.RefundRequests.OrderBy(r => r.CreationTime); if (resourceParameters.IsSolved != null) { beforePaging = beforePaging.Where(p => p.Solved == resourceParameters.IsSolved); } return(PagedList <RefundRequest> .Create(beforePaging, resourceParameters.PageNumber, resourceParameters.PageSize)); }