public static SettingEntry ToModel(this ModuleSetting moduleSetting, SettingEntity entity, string groupName)
        {
            var result = new SettingEntry();

            result.InjectFrom(moduleSetting);

            result.Value     = moduleSetting.DefaultValue;
            result.ValueType = ConvertToSettingValueType(moduleSetting.ValueType);
            result.GroupName = groupName;

            if (entity != null)
            {
                var existingValues = entity.SettingValues.Select(x => x.ToString(CultureInfo.InvariantCulture)).ToArray();

                if (moduleSetting.IsArray)
                {
                    result.ArrayValues = existingValues;
                }
                else
                {
                    if (existingValues.Any())
                    {
                        result.Value = existingValues.First();
                    }
                }
            }

            return(result);
        }
Esempio n. 2
0
        public static SettingEntry ToWebModel(this VirtoCommerceStoreModuleWebModelSetting dto)
        {
            var retVal = new SettingEntry();

            retVal.InjectFrom <NullableAndEnumValueInjecter>(dto);
            retVal.AllowedValues = dto.AllowedValues;
            retVal.ArrayValues   = dto.ArrayValues;
            return(retVal);
        }
Esempio n. 3
0
        public static SettingEntry ToSettingEntry(this platformDto.Setting settingDto)
        {
            var retVal = new SettingEntry();

            retVal.InjectFrom <NullableAndEnumValueInjecter>(settingDto);
            retVal.AllowedValues = settingDto.AllowedValues;
            retVal.ArrayValues   = settingDto.ArrayValues;
            return(retVal);
        }
        public static SettingEntry ToModel(this SettingEntity entity)
        {
            var result = new SettingEntry();

            result.InjectFrom(entity);
            result.ValueType = (SettingValueType)Enum.Parse(typeof(SettingValueType), entity.SettingValueType);
            var existingValues = entity.SettingValues.Select(x => x.ToString(CultureInfo.InvariantCulture)).ToArray();

            if (entity.IsEnum)
            {
                result.ArrayValues = existingValues;
            }
            else
            {
                if (existingValues.Any())
                {
                    result.Value = existingValues.First();
                }
            }
            return(result);
        }