Exemplo n.º 1
0
 public virtual void Patch(PropertyDictionaryItemEntity target)
 {
     target.Alias = Alias;
     if (!DictionaryItemValues.IsNullCollection())
     {
         var comparer = AnonymousComparer.Create((PropertyDictionaryValueEntity x) => x.Value + '|' + x.Locale);
         DictionaryItemValues.Patch(target.DictionaryItemValues, comparer, (sourceDictItem, targetDictItem) => sourceDictItem.Patch(targetDictItem));
     }
 }
Exemplo n.º 2
0
        public virtual PropertyEntity FromModel(Property property, PrimaryKeyResolvingMap pkMap)
        {
            if (property == null)
            {
                throw new ArgumentNullException(nameof(property));
            }

            pkMap.AddPair(property, this);

            Id           = property.Id;
            CreatedBy    = property.CreatedBy;
            CreatedDate  = property.CreatedDate;
            ModifiedBy   = property.ModifiedBy;
            ModifiedDate = property.ModifiedDate;

            CatalogId  = property.CatalogId;
            CategoryId = property.CategoryId;

            Name = property.Name;
            PropertyValueType = (int)property.ValueType;
            IsMultiValue      = property.Multivalue;
            IsLocaleDependant = property.Multilanguage;
            IsEnum            = property.Dictionary;
            IsRequired        = property.Required;
            TargetType        = property.Type.ToString();

            if (property.Attributes != null)
            {
                PropertyAttributes = new ObservableCollection <PropertyAttributeEntity>(property.Attributes.Select(x => AbstractTypeFactory <PropertyAttributeEntity> .TryCreateInstance().FromModel(x, pkMap)));
            }
#pragma warning disable 612, 618
            //Left for backward compatibility, when the dictionary items of the property  can only be changed with the property
            if (property.DictionaryValues != null)
            {
                DictionaryItems = new ObservableCollection <PropertyDictionaryItemEntity>(PropertyDictionaryItemEntity.FromModels(property.DictionaryValues, pkMap));
            }
#pragma warning restore 612, 618
            if (property.DisplayNames != null)
            {
                DisplayNames = new ObservableCollection <PropertyDisplayNameEntity>(property.DisplayNames.Select(x => AbstractTypeFactory <PropertyDisplayNameEntity> .TryCreateInstance().FromModel(x)));
            }

            if (property.ValidationRules != null)
            {
                ValidationRules = new ObservableCollection <PropertyValidationRuleEntity>(property.ValidationRules.Select(x => AbstractTypeFactory <PropertyValidationRuleEntity> .TryCreateInstance().FromModel(x)));
            }
            return(this);
        }