Esempio n. 1
0
        public FeatureToggleValue AddOrEditFeatureToggleValue(Guid featureToggleId, bool isEnabled)
        {
            var featureToggleValue = FeatureToggleValues.FirstOrDefault(x => x.FeatureToggleId == featureToggleId);

            if (featureToggleValue == null)
            {
                featureToggleValue = FeatureToggleValue.NewValue(isEnabled, Id, featureToggleId);
                FeatureToggleValues.Add(featureToggleValue);
            }
            else
            {
                if (isEnabled)
                {
                    featureToggleValue.Enable();
                }
                else
                {
                    featureToggleValue.Disable();
                }
            }

            LastUpdateAt = DateTime.UtcNow;

            return(featureToggleValue);
        }
Esempio n. 2
0
        public FeatureToggleValue AddOrEditFeatureToggleValue(string key, string description, bool isEnabled)
        {
            var application = Application;
            var toggle      = application.FeatureToggles.FirstOrDefault(x => x.Key == key);

            if (toggle == null)
            {
                toggle = application.AddNewFeatureToggle(key, description);
            }

            var featureValue = FeatureToggleValues.FirstOrDefault(x => x.FeatureToggleId == toggle.Id);

            if (featureValue == null)
            {
                featureValue = FeatureToggleValue.NewValue(isEnabled, Id, toggle.Id);
                FeatureToggleValues.Add(featureValue);
            }
            else
            {
                if (isEnabled)
                {
                    featureValue.Enable();
                }
                else
                {
                    featureValue.Disable();
                }
            }
            LastUpdateAt = DateTime.UtcNow;

            return(featureValue);
        }