public IActionResult Index()

in labs/vstsextend/launchdarkly/codesnippet/HomeController.cs [31:72]


        public IActionResult Index()
        {
            // Get most popular products
            List<Product> topSellingProducts;
            if (!_cache.TryGetValue("topselling", out topSellingProducts))
            {
                topSellingProducts = GetTopSellingProducts(4);
                //Refresh it every 10 minutes. Let this be the last item to be removed by cache if cache GC kicks in.
                _cache.Set("topselling", topSellingProducts, new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromMinutes(10)).SetPriority(CacheItemPriority.High));
            }
            
            List<Product> newProducts;
            if (!_cache.TryGetValue("newarrivals", out newProducts))
            {
                newProducts = GetNewProducts(4);
                //Refresh it every 10 minutes. Let this be the last item to be removed by cache if cache GC kicks in.
                _cache.Set("newarrivals", newProducts, new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromMinutes(10)).SetPriority(CacheItemPriority.High));
            }

            var viewModel = new HomeViewModel
            {
                NewProducts = newProducts,
                TopSellingProducts = topSellingProducts,
                CommunityPosts = GetCommunityPosts()
            };
            var category = _db.Categories.ToList();
            //LaunchDarkly start
            User user = LaunchDarkly.Client.User.WithKey("administrator@test.com");
            bool value = client.BoolVariation("member-portal", user, false);
            if (value)
            {
                ViewBag.Message = "Your application description page.";
                ViewData["togglevalue"] = value;
                return View(viewModel);
            }
            else
            {
                return View(viewModel);
            }
           // return View(viewModel);

        }