public JsonResult GetConfigurationInstance(string modelName)
        {
            // Get the FeatureModel
            ModelManager manager = new ModelManager(_modelFolderPath);

            Core.Modelling.BLOs.Model targetModel = manager.GetModelByFileNameInFolder(modelName);

            // Create a ConfiguratorSession and store it in the session
            ConfigurationInstanceManager configurationInstanceManager = new ConfigurationInstanceManager(_configurationInstanceFolderPath);
            ConfiguratorSession          configSession = configurationInstanceManager.CreateConfiguratorSession(targetModel);

            HttpContext.Session["configuratorSession"] = configSession;

            // Toggle the root feature, as an initial starting point
            configSession.ToggleFeatureAsUser(configSession.configurationInstance.RootFeatureSelection.FeatureIdentifier);


            //
            return(Json(configSession.configurationInstance, JsonRequestBehavior.AllowGet));
        }
        public JsonResult ToggleFeatureSelection([FromBody] FeatureIDModel model)
        {
            // Get the ConfiguratorSession from the session state and Toggle the value
            ConfiguratorSession     configSession            = (ConfiguratorSession)HttpContext.Session["configuratorSession"];
            List <FeatureSelection> changedFeatureSelections = configSession.ToggleFeatureAsUser(model.FeatureID);

            // Make a dictionary with changes for each FeatureSelection
            Dictionary <string, object> changesDictionary = new Dictionary <string, object>();

            foreach (FeatureSelection changedFeatureSelection in changedFeatureSelections)
            {
                var featureSelectionChanges = new
                {
                    SelectionState        = changedFeatureSelection.SelectionState,
                    Disabled              = changedFeatureSelection.Disabled,
                    ToggledByUser         = changedFeatureSelection.ToggledByUser,
                    AttributeValueChanges = new List <object>()
                };

                // Child attribute values
                foreach (AttributeValue changedAttrVal in changedFeatureSelection.AttributeValues)
                {
                    featureSelectionChanges.AttributeValueChanges.Add(new
                    {
                        AttributeIdentifier = changedAttrVal.AttributeIdentifier,
                        Value = changedAttrVal.Value
                    });
                }

                changesDictionary.Add(changedFeatureSelection.FeatureIdentifier, featureSelectionChanges);
            }

            //
            var returnModel = new ToggleFeatureReturnModel();

            returnModel.ChangesDictionary = changesDictionary;
            returnModel.SMTDynamicText    = configSession.solverContext.GetSMTDynamicText;
            return(Json(returnModel));
        }