Example #1
0
        public ExpandoObject CreateLinkedentityWithmetadataObject <T>(
            PaginationMetaDataObject paginationMetadata,
            IEnumerable <T> objs, IEnumerable <LinksObject> links)
        {
            var objWithMetadata = new ExpandoObject();

            ((IDictionary <string, object>)objWithMetadata).Add("metadata", paginationMetadata);
            ((IDictionary <string, object>)objWithMetadata).Add("records", objs);
            ((IDictionary <string, object>)objWithMetadata).Add("links", links);
            return(objWithMetadata);
        }
Example #2
0
        public PaginationMetaDataObject CreatePaginationMetadataObject <T>(PagedList <T> pagedlist, RequestParameters requestParameters, string routeName)
        {
            var previousPageLink = pagedlist.HasPrevious ? _paginationUrlHelper.CreateUrlForResource(requestParameters, PageType.PreviousPage, routeName) : null;
            var nextPageLink     = pagedlist.HasNext ? _paginationUrlHelper.CreateUrlForResource(requestParameters, PageType.NextPage, routeName) : null;

            var paginationMetaData = new PaginationMetaDataObject()
            {
                TotalCount       = pagedlist.TotalCount,
                PageSize         = pagedlist.PageSize,
                CurrentPage      = pagedlist.CurrentPage,
                TotalPages       = pagedlist.TotalPages,
                PreviousPageLink = previousPageLink,
                NextPageLink     = nextPageLink
            };

            return(paginationMetaData);
        }