Example #1
0
        public virtual void ActualizeValues()
        {
            var dictLocalizedValues = new List <PropertyValue>();

            if (Values != null)
            {
                foreach (var propValue in Values)
                {
                    if (Dictionary && DictionaryValues != null)
                    {
                        /// Actualize  dictionary property value from property meta-information instead stored
                        if (propValue.ValueId != null)
                        {
                            var dictValue = DictionaryValues.FirstOrDefault(x => x.Id == propValue.ValueId);
                            if (dictValue != null)
                            {
                                propValue.Value = dictValue.Value;
                            }
                        }
                        if (Multilanguage)
                        {
                            foreach (var dictValue in DictionaryValues.Where(x => x.Alias.EqualsInvariant(propValue.Alias)))
                            {
                                var langDictPropValue = propValue.Clone() as PropertyValue;
                                langDictPropValue.Id           = null;
                                langDictPropValue.LanguageCode = dictValue.LanguageCode;
                                langDictPropValue.Value        = dictValue.Value;
                                dictLocalizedValues.Add(langDictPropValue);
                            }
                        }
                    }
                }
                foreach (var localizedDictValue in dictLocalizedValues)
                {
                    if (!Values.Any(x => x.Alias.EqualsInvariant(localizedDictValue.Alias) && x.LanguageCode.EqualsInvariant(localizedDictValue.LanguageCode)))
                    {
                        Values.Add(localizedDictValue);
                    }
                }
            }
        }