protected async Task <IActionResult> Get(int?page = DefaultPage, int?pageSize = DefaultPageSize, TEntityFilter filter = null) { if (page == null) { page = DefaultPage; } if (page < 1) { page = DefaultPage; } if (pageSize == null) { pageSize = DefaultPageSize; } if (pageSize > MaximumPageSize) { pageSize = MaximumPageSize; } var pagedModels = await _repository.GetPaginatedEntitiesAsync(page.Value, pageSize.Value, filter); var mappedModels = pagedModels.Select(pm => _modelMapper.Map(pm, Url)); var pagingLinks = _pagingLinksFactory.Create(pagedModels, Url, filter); Response.Headers.AddLinkHeader(pagingLinks); return(Ok(mappedModels)); }