public async Task <IActionResult> IndexAsync()
        {
            var products = await _productApiClient.GetProducts();

            foreach (var x in products)
            {
                //for (int i = 0; i < x.ImageLocation.Count; i++)
                //{
                x.Images = _configuration["BackendUrl:Default"] + x.Images;
                //    x.ImageLocation[i] = setUrl;
                //}
            }
            return(View(products));
        }
Example #2
0
        public async Task <IActionResult> Index()
        {
            var products = await _productAPI.GetProducts();

            //Set url backend for image
            foreach (var x in products)
            {
                //for (int i = 0; i < x.Images.Count(); i++)
                //{
                x.Images = _configuration["BackendUrl:Default"] + x.Images;
                //    x.Images[i] = setUrl;
                //}
            }
            return(View(products));
        }
Example #3
0
        /// <summary>
        /// Return product and sort it based on the sort option
        /// </summary>
        /// <param name="sortOption">define how products should be sort</param>
        /// <param name="token">token to access the api</param>
        /// <returns>sorted product</returns>
        public async Task <List <Product> > GetProducts(string sortOption, string token)
        {
            var option   = ParseOption(sortOption);
            var products = await _productAPI.GetProducts(token);

            List <Product> result;

            if (option == SortOption.Recommended)
            {
                result = await SortByPopularity(token, products);
            }
            else
            {
                result = SortByProductAttribute(option, products);
            }

            return(result);
        }
Example #4
0
        public async Task <IViewComponentResult> InvokeAsync()
        {
            var products = await _productApiClient.GetProducts();

            return(View(products));
        }