public PaginatedResultVm <T> GetCursorPaginatedResult <T>(PageOptionsCursor pageOptions, bool hasNextPage, bool hasPreviousPage, int totalCount, string startCursor, string endCursor, string routeName, ICollection <T> items) where T : class { ArgumentNullException.ThrowIfNull(pageOptions); if (string.IsNullOrEmpty(routeName)) { throw new ArgumentNullException(nameof(routeName)); } ICollection <T> resultItems = items ?? new List <T>(); Tuple <ExpandoObject, ExpandoObject> baseQueryParams = GetCursorUniqueQueryParams(pageOptions); PageInfoVm pageInfo = new PageInfoVm() { Count = items.Count, HasNextPage = hasNextPage, HasPreviousPage = hasPreviousPage, NextPageUrl = hasNextPage ? GetCursorNextPageUri(routeName, baseQueryParams, pageOptions, endCursor) : null, PreviousPageUrl = hasPreviousPage ? GetCursorPreviousPageUri(routeName, baseQueryParams, pageOptions, startCursor) : null, FirstPageUrl = GetCursorFirstPageUri(routeName, baseQueryParams, pageOptions), LastPageUrl = GetCursorLastPageUri(routeName, baseQueryParams, pageOptions), }; PaginatedResultVm <T> result = new PaginatedResultVm <T>(totalCount, pageInfo, resultItems); return(result); }
public PaginatedResultVm(int totalCount, PageInfoVm pageInfo, ICollection <T> items) { TotalCount = totalCount; PageInfo = pageInfo ?? throw new ArgumentNullException(nameof(pageInfo)); Items = items ?? throw new ArgumentNullException(nameof(items)); }