예제 #1
0
 private void SelfLink(PagedListResult <Product> products, SrvObj.ProductsResponse productResponse)
 {
     productResponse
     .Links
     .Add(NewLink("self", "products?page={0}&size={1}"
                  .Fmt(products.Page, products.Size)));
 }
예제 #2
0
        private void LastLink(PagedListResult <Product> products, SrvObj.ProductsResponse productResponse)
        {
            var lastPage = products.LastPage();

            productResponse
            .Links
            .Add(NewLink("last", "products?page={0}&size={1}".Fmt(lastPage, products.Size)));
        }
예제 #3
0
 private void PreviousLink(PagedListResult <Product> products, SrvObj.ProductsResponse productResponse)
 {
     if (products.HasPrevious)
     {
         productResponse
         .Links
         .Add(NewLink("previous", "products?page={0}&size={1}"
                      .Fmt(products.Page - 1, products.Size)));
     }
 }
예제 #4
0
 private void NextLink(PagedListResult <Product> products, SrvObj.ProductsResponse productResponse)
 {
     if (products.HasNext)
     {
         productResponse
         .Links
         .Add(NewLink("next", "products?page={0}&size={1}"
                      .Fmt(products.Page + 1, products.Size)));
     }
 }
예제 #5
0
        public SrvObj.ProductsResponse ToProductsResponse(PagedListResult <Product> products)
        {
            var productList = ToProductResponseList(products.Entities.ToList());

            var productResponse = new SrvObj.ProductsResponse();

            productResponse.Products = productList;

            SelfLink(products, productResponse);

            NextLink(products, productResponse);

            PreviousLink(products, productResponse);

            FirstLink(products, productResponse);

            LastLink(products, productResponse);

            return(productResponse);
        }
예제 #6
0
 private void FirstLink(PagedListResult <Product> products, SrvObj.ProductsResponse productResponse)
 {
     productResponse
     .Links
     .Add(NewLink("first", "products?page=1&size={0}".Fmt(products.Size)));
 }