public override void Process(ExecuteSubmitActionsEventArgs args)
        {
            var tokenMap = fieldBindingMapFactory.GetFieldBindingTokenMap();

            if (tokenMap == null)
            {
                return;
            }
            var valuesUpdated = false;

            foreach (var fieldModel in args.FormSubmitContext.Fields)
            {
                if (!(fieldModel is IBindingSettings bindingSettings))
                {
                    continue;
                }
                if (!bindingSettings.StoreBindingValue)
                {
                    continue;
                }
                if (string.IsNullOrEmpty(bindingSettings.BindingToken))
                {
                    continue;
                }
                if (!tokenMap.ContainsKey(new FieldBindingTokenKey(bindingSettings.BindingToken)))
                {
                    continue;
                }
                var tokenHandler = tokenMap[new FieldBindingTokenKey(bindingSettings.BindingToken)];

                var property = fieldModel.GetType().GetProperty("Value");
                if (property == null)
                {
                    continue;
                }

                var value = property.GetValue(fieldModel);
                if (value != null)
                {
                    tokenHandler.StoreBindingValue(value);
                    valuesUpdated = true;
                }
            }
            if (valuesUpdated)
            {
                xDbService.ReloadContactDataIntoSession();
            }
        }
Beispiel #2
0
        public override void Process(ExecuteSubmitActionsEventArgs args)
        {
            if (args?.FormSubmitContext?.Fields == null)
            {
                return;
            }
            var valuesUpdated = false;

            foreach (var fieldModel in args.FormSubmitContext.Fields)
            {
                if (!(fieldModel is IBindingSettings bindingSettings))
                {
                    continue;
                }
                if (!bindingSettings.StoreBindingValue)
                {
                    continue;
                }
                if (string.IsNullOrEmpty(bindingSettings.ValueProviderSettings?.ValueProviderItemId))
                {
                    continue;
                }
                var bindingHandler = fieldBindingMapFactory.GetBindingHandler(bindingSettings.ValueProviderSettings);

                var property = fieldModel.GetType().GetProperty("Value");
                if (property == null)
                {
                    continue;
                }

                var value = property.GetValue(fieldModel);
                if (value == null)
                {
                    continue;
                }
                bindingHandler.StoreBindingValue(value);
                valuesUpdated = true;
            }
            if (valuesUpdated)
            {
                xDbService.ReloadContactDataIntoSession();
            }
        }