/// <summary> /// Converting to foundation type /// </summary> /// <param name="catalog"></param> /// <returns></returns> public static dataModel.Property ToDataModel(this coreModel.Property property) { if (property == null) { throw new ArgumentNullException("property"); } var retVal = new dataModel.Property(); retVal.InjectFrom(property); retVal.PropertyValueType = (int)property.ValueType; retVal.IsMultiValue = property.Multivalue; retVal.IsLocaleDependant = property.Multilanguage; retVal.IsEnum = property.Dictionary; retVal.IsRequired = property.Required; retVal.TargetType = property.Type.ToString(); if (property.Attributes != null) { retVal.PropertyAttributes = new ObservableCollection <dataModel.PropertyAttribute>(); foreach (var attribute in property.Attributes) { var dbAttribute = attribute.ToDataModel(); retVal.PropertyAttributes.Add(dbAttribute); } } if (property.DictionaryValues != null) { retVal.DictionaryValues = new ObservableCollection <dataModel.PropertyDictionaryValue>(); foreach (var dictValue in property.DictionaryValues) { var dbDictValue = dictValue.ToDataModel(); retVal.DictionaryValues.Add(dbDictValue); } } if (property.DisplayNames != null) { foreach (var displayName in property.DisplayNames.Where(x => !String.IsNullOrEmpty(x.Name))) { var attributeName = "DisplayName" + displayName.LanguageCode; var existAttribute = retVal.PropertyAttributes.FirstOrDefault(x => x.PropertyAttributeName == attributeName); if (existAttribute == null) { existAttribute = new dataModel.PropertyAttribute { PropertyId = property.Id, PropertyAttributeName = attributeName, }; retVal.PropertyAttributes.Add(existAttribute); } existAttribute.PropertyAttributeValue = displayName.Name; } } return(retVal); }
/// <summary> /// Converting to foundation type /// </summary> /// <param name="catalog"></param> /// <returns></returns> public static dataModel.PropertyAttribute ToDataModel(this coreModel.PropertyAttribute attribute) { var retVal = new dataModel.PropertyAttribute(); retVal.InjectFrom(attribute); retVal.PropertyAttributeName = attribute.Name; retVal.PropertyAttributeValue = attribute.Value; return(retVal); }
/// <summary> /// Converting to foundation type /// </summary> /// <param name="catalog"></param> /// <returns></returns> public static dataModel.PropertyAttribute ToDataModel(this coreModel.PropertyAttribute attribute) { var retVal = new dataModel.PropertyAttribute(); retVal.InjectFrom(attribute); retVal.PropertyAttributeName = attribute.Name; retVal.PropertyAttributeValue = attribute.Value; return retVal; }
/// <summary> /// Patch CatalogLanguage type /// </summary> /// <param name="source"></param> /// <param name="target"></param> public static void Patch(this dataModel.PropertyAttribute source, dataModel.PropertyAttribute target) { if (target == null) { throw new ArgumentNullException("target"); } var patchInjectionPolicy = new PatchInjection <dataModel.PropertyAttribute>(x => x.PropertyAttributeName, x => x.PropertyAttributeValue); target.InjectFrom(patchInjectionPolicy, source); }
/// <summary> /// Converting to foundation type /// </summary> /// <param name="catalog"></param> /// <returns></returns> public static dataModel.PropertyAttribute ToDataModel(this coreModel.PropertyAttribute attribute) { var retVal = new dataModel.PropertyAttribute(); var id = retVal.Id; retVal.InjectFrom(attribute); if(attribute.Id == null) { retVal.Id = id; } retVal.PropertyAttributeName = attribute.Name; retVal.PropertyAttributeValue = attribute.Value; return retVal; }
/// <summary> /// Converting to foundation type /// </summary> /// <param name="catalog"></param> /// <returns></returns> public static dataModel.PropertyAttribute ToDataModel(this coreModel.PropertyAttribute attribute) { var retVal = new dataModel.PropertyAttribute(); var id = retVal.Id; retVal.InjectFrom(attribute); if (attribute.Id == null) { retVal.Id = id; } retVal.PropertyAttributeName = attribute.Name; retVal.PropertyAttributeValue = attribute.Value; return(retVal); }
/// <summary> /// Converting to model type /// </summary> /// <param name="catalogBase"></param> /// <returns></returns> public static coreModel.PropertyAttribute ToCoreModel(this dataModel.PropertyAttribute dbAttribute, coreModel.Property property) { if (property == null) { throw new ArgumentNullException("dbProperty"); } var retVal = new coreModel.PropertyAttribute(); retVal.InjectFrom(dbAttribute); retVal.Name = dbAttribute.PropertyAttributeName; retVal.Value = dbAttribute.PropertyAttributeValue; retVal.PropertyId = property.Id; retVal.Property = property; return(retVal); }
public virtual PropertyAttribute ToModel(PropertyAttribute attribute) { if (attribute == null) { throw new ArgumentNullException(nameof(attribute)); } attribute.Id = this.Id; attribute.CreatedBy = this.CreatedBy; attribute.CreatedDate = this.CreatedDate; attribute.ModifiedBy = this.ModifiedBy; attribute.ModifiedDate = this.ModifiedDate; attribute.Name = this.PropertyAttributeName; attribute.Value = this.PropertyAttributeValue; attribute.PropertyId = this.PropertyId; return(attribute); }
public virtual PropertyAttributeEntity FromModel(PropertyAttribute attribute, PrimaryKeyResolvingMap pkMap) { if (attribute == null) { throw new ArgumentNullException(nameof(attribute)); } pkMap.AddPair(attribute, this); this.Id = attribute.Id; this.CreatedBy = attribute.CreatedBy; this.CreatedDate = attribute.CreatedDate; this.ModifiedBy = attribute.ModifiedBy; this.ModifiedDate = attribute.ModifiedDate; this.PropertyId = attribute.PropertyId; this.PropertyAttributeName = attribute.Name; this.PropertyAttributeValue = attribute.Value; return(this); }
/// <summary> /// Converting to foundation type /// </summary> /// <param name="catalog"></param> /// <returns></returns> public static dataModel.Property ToDataModel(this coreModel.Property property) { if (property == null) throw new ArgumentNullException("property"); var retVal = new dataModel.Property(); var id = retVal.Id; retVal.InjectFrom(property); if(property.Id == null) { retVal.Id = id; } retVal.PropertyValueType = (int)property.ValueType; retVal.IsMultiValue = property.Multivalue; retVal.IsLocaleDependant = property.Multilanguage; retVal.IsEnum = property.Dictionary; retVal.IsRequired = property.Required; retVal.TargetType = property.Type.ToString(); if (property.Attributes != null) { retVal.PropertyAttributes = new ObservableCollection<dataModel.PropertyAttribute>(); foreach (var attribute in property.Attributes) { var dbAttribute = attribute.ToDataModel(); retVal.PropertyAttributes.Add(dbAttribute); } } if (property.DictionaryValues != null) { retVal.PropertyValues = new ObservableCollection<dataModel.PropertyValue>(); foreach (var dictValue in property.DictionaryValues) { var dbDictValue = dictValue.ToDataModel(property); retVal.PropertyValues.Add(dbDictValue); } } if (property.DisplayNames != null) { foreach (var displayName in property.DisplayNames.Where(x=> !String.IsNullOrEmpty(x.Name))) { var attributeName = "DisplayName" + displayName.LanguageCode; var existAttribute = retVal.PropertyAttributes.FirstOrDefault(x => x.PropertyAttributeName == attributeName); if(existAttribute == null) { existAttribute = new dataModel.PropertyAttribute { PropertyId = property.Id, PropertyAttributeName = attributeName, }; retVal.PropertyAttributes.Add(existAttribute); } existAttribute.PropertyAttributeValue = displayName.Name; } } return retVal; }