Exemplo n.º 1
0
        private IHttpActionResult getProduct(string slug, string productBadge, [FromUri] CategoryPageParameterModel parameter)
        {
            var pagination = new PaginationMetadataModel()
            {
                currentPage = parameter.pageNumber,
                pageSize    = parameter.pageSize
            };
            var filter = new CategoryPageFilterModel()
            {
                categorySlug = slug,
                productBadge = productBadge,
                priceMin     = parameter.priceMin,
                priceMax     = parameter.priceMax,
                sort         = parameter.sort
            };
            var products = _service.getProducts(filter, ref pagination);

            if (products == null || products.Count == 0)
            {
                return(NotFound());
            }

            // Setting Header
            HttpContext.Current.Response.Headers.Add("Access-Control-Expose-Headers", "X-Paging-Headers");
            HttpContext.Current.Response.Headers.Add("X-Paging-Headers", JsonConvert.SerializeObject(pagination));

            // Returing List of product Collections
            return(Ok <List <ProductCardModel> >(products));
        }
Exemplo n.º 2
0
 public IHttpActionResult GetProductByCategory(string slug, [FromUri] CategoryPageParameterModel parameter)
 {
     return(this.getProduct(slug, String.Empty, parameter));
 }
Exemplo n.º 3
0
 public IHttpActionResult GetProductOrderByCategory(string slug, string productBadge, [FromUri] CategoryPageParameterModel parameter)
 {
     return(this.getProduct(slug, productBadge, parameter));
 }
Exemplo n.º 4
0
 public IHttpActionResult GetProductOrderAll(string productBadge, [FromUri] CategoryPageParameterModel parameter)
 {
     return(this.getProduct(String.Empty, productBadge, parameter));
 }
Exemplo n.º 5
0
 public IHttpActionResult GetProductAll([FromUri] CategoryPageParameterModel parameter)
 {
     return(this.getProduct(String.Empty, String.Empty, parameter));
 }