Example #1
0
        public async Task <ActionResult <List <Product> > > Get([FromQuery] int userId)
        {
            var  ldUser            = LaunchDarkly.Client.User.WithKey("1");
            bool killSwitchEnabled = _ldClient.BoolVariation("killswitch.getproducts", ldUser, false);

            if (killSwitchEnabled)
            {
                // application code to show the feature
                return(Ok(new List <Product>()));
            }

            List <Product> products;

            if (userId > 0)
            {
                Core.Models.User user = await _usersProvider.FindUserById(userId);

                products = await _productsProvider.GetFoodProductsByCarbsForUser(user);
            }
            else
            {
                products = await _productsProvider.GetFoodProductsByCarbs();
            }

            products = products ?? new List <Product>();

            return(Ok(products.ToList()));
        }