Пример #1
0
        public IHttpActionResult ProductComplexList(int page = 1)
        {
            int pageSize       = 10;
            var productComplex = _productService.GetAllProductWithCategory().OrderByDescending(_ => _.ProductId).ToList();

            ProductWithCategoryResponse ProductComplexResponse = new ProductWithCategoryResponse
            {
                Products  = productComplex.Skip((page - 1) * pageSize).Take(pageSize).ToList(),
                PageCount = (int)Math.Ceiling(productComplex.Count / (double)pageSize),
                PageSize  = pageSize,
            };

            return(Ok(ProductComplexResponse));
        }
Пример #2
0
        public IActionResult ProductComplexList(int page = 1)
        {
            //Thread.Sleep(5000);

            try
            {
                int pageSize       = 10;
                var productComplex = _productService.GetAllProductWithCategory().OrderByDescending(_ => _.ProductId).ToList();

                ProductWithCategoryResponse ProductComplexResponse = new ProductWithCategoryResponse
                {
                    Products  = productComplex.Skip((page - 1) * pageSize).Take(pageSize).ToList(),
                    PageCount = (int)Math.Ceiling(productComplex.Count / (double)pageSize),
                    PageSize  = pageSize,
                };

                return(Ok(ProductComplexResponse));
            }
            catch
            {
                return(BadRequest("An error has occurred"));
            }
        }