public static NavigationQueries Build <TSortPropertyEnum, TQueryFilter, TEntitiy>(QueryBase <TSortPropertyEnum, TQueryFilter> query, QueryResult <TEntitiy> queryResult) where TSortPropertyEnum : struct where TQueryFilter : IQueryFilter, new() { var result = new NavigationQueries(); if (!query.Pagination.HasPagination() || queryResult.TotalCountOfEnties <= 0) { return(result); } result.AddQuery(DefaultHypermediaRelations.Queries.All, CreateQueryAll(query)); QueryBase <TSortPropertyEnum, TQueryFilter> createdQuery; if (TryCreateQueryFirst(query, queryResult.TotalCountOfEnties, out createdQuery)) { result.AddQuery(DefaultHypermediaRelations.Queries.First, createdQuery); } if (TryCreateQueryNext(query, queryResult.TotalCountOfEnties, out createdQuery)) { result.AddQuery(DefaultHypermediaRelations.Queries.Next, createdQuery); } if (TryCreateQueryPrevious(query, queryResult.TotalCountOfEnties, out createdQuery)) { result.AddQuery(DefaultHypermediaRelations.Queries.Previous, createdQuery); } if (TryCreateQueryLast(query, queryResult.TotalCountOfEnties, out createdQuery)) { result.AddQuery(DefaultHypermediaRelations.Queries.Last, createdQuery); } return(result); }
public static bool HasPreviousPage <TSortPropertyEnum, TQueryFilter>(QueryBase <TSortPropertyEnum, TQueryFilter> query, int queryResultCount) where TSortPropertyEnum : struct where TQueryFilter : IQueryFilter, new() { return(query.Pagination.PageOffset > 0); }
public static bool HasLastPage <TSortPropertyEnum, TQueryFilter>(QueryBase <TSortPropertyEnum, TQueryFilter> query, int queryResultCount) where TSortPropertyEnum : struct where TQueryFilter : IQueryFilter, new() { return(queryResultCount > query.Pagination.PageSize); }
public static QueryBase <TSortPropertyEnum, TQueryFilter> CreateQueryAll <TSortPropertyEnum, TQueryFilter>(QueryBase <TSortPropertyEnum, TQueryFilter> queryParameters) where TSortPropertyEnum : struct where TQueryFilter : IQueryFilter, new() { var result = queryParameters.Clone(); result.Pagination.DisablePagination(); return(result); }