public string CreateCustomAttributesResourceUri(ResourceUriType type, CustomAttributeResourceParameters customAttributeResourceParameters) { switch (type) { case ResourceUriType.PreviousPage: return(_linkGenerator.GetPathByName(_accessor.HttpContext, "GetCustomAttributesByIdentifier", new { orderBy = customAttributeResourceParameters.OrderBy, ExtendableTypeName = customAttributeResourceParameters.ExtendableTypeName.ToString(), CustomAttributeType = customAttributeResourceParameters.CustomAttributeType.ToString(), isSearchable = customAttributeResourceParameters.IsSearchable, pageNumber = customAttributeResourceParameters.PageNumber - 1, pageSize = customAttributeResourceParameters.PageSize })); case ResourceUriType.NextPage: return(_linkGenerator.GetPathByName(_accessor.HttpContext, "GetCustomAttributesByIdentifier", new { orderBy = customAttributeResourceParameters.OrderBy, ExtendableTypeName = customAttributeResourceParameters.ExtendableTypeName.ToString(), CustomAttributeType = customAttributeResourceParameters.CustomAttributeType.ToString(), isSearchable = customAttributeResourceParameters.IsSearchable, pageNumber = customAttributeResourceParameters.PageNumber + 1, pageSize = customAttributeResourceParameters.PageSize })); case ResourceUriType.Current: default: return(_linkGenerator.GetPathByName(_accessor.HttpContext, "GetCustomAttributesByIdentifier", new { orderBy = customAttributeResourceParameters.OrderBy, ExtendableTypeName = customAttributeResourceParameters.ExtendableTypeName.ToString(), CustomAttributeType = customAttributeResourceParameters.CustomAttributeType.ToString(), isSearchable = customAttributeResourceParameters.IsSearchable, pageNumber = customAttributeResourceParameters.PageNumber, pageSize = customAttributeResourceParameters.PageSize })); } }
public async Task <ActionResult <LinkedCollectionResourceWrapperDto <CustomAttributeIdentifierDto> > > GetCustomAttributesByIdentifier( [FromQuery] CustomAttributeResourceParameters customAttributeResourceParameters) { if (!_typeHelperService.TypeHasProperties <CustomAttributeIdentifierDto> (customAttributeResourceParameters.OrderBy)) { return(BadRequest()); } var query = new CustomAttributesIdentifierQuery( customAttributeResourceParameters.OrderBy, customAttributeResourceParameters.ExtendableTypeName, customAttributeResourceParameters.CustomAttributeType, customAttributeResourceParameters.IsSearchable, customAttributeResourceParameters.PageNumber, customAttributeResourceParameters.PageSize); _logger.LogInformation( "----- Sending query: CustomAttributesIdentifierQuery"); var queryResult = await _mediator.Send(query); if (queryResult == null) { return(BadRequest("Query not created")); } // Prepare pagination data for response var paginationMetadata = new { totalCount = queryResult.RecordCount, pageSize = customAttributeResourceParameters.PageSize, currentPage = customAttributeResourceParameters.PageNumber, totalPages = queryResult.PageCount }; Response.Headers.Add("X-Pagination", JsonConvert.SerializeObject(paginationMetadata)); return(Ok(queryResult)); }