public async Task <DropshipItem[]> GetProducts()
        {
            var response = await api.Get(ApiEndpoints.DropshipGetProducts(0, 28));

            if (response.IsSuccessStatusCode)
            {
                var json = await response.Content.ReadAsStringAsync();

                var products = JsonConvert.DeserializeObject <DropshipItem[]>(json);
                return(products);
            }

            return(new DropshipItem[0]);
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Products(int page = 1)
        {
            var response = await api.Get(ApiEndpoints.DropshipGetProducts(productsPerPage * (page - 1), productsPerPage));

            var products = new DropshipItem[0];

            if (response.IsSuccessStatusCode)
            {
                var json = await response.Content.ReadAsStringAsync();

                products = JsonConvert.DeserializeObject <DropshipItem[]>(json);
            }

            //Add total count for pagination
            ViewBag.MaxCount     = response.Headers.Contains("X-Total-Count") ? Convert.ToInt32(response.Headers.GetValues("X-Total-Count").First()) : productsPerPage;
            ViewBag.Page         = page;
            ViewBag.ItemsPerPage = productsPerPage;

            return(View(products));
        }