Beispiel #1
0
        /// <summary>
        /// Converting to model type
        /// </summary>
        /// <param name="dbPropValue">The database property value.</param>
        /// <param name="properties">The properties.</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException">dbPropValue</exception>
        public static coreModel.PropertyValue ToCoreModel(this dataModel.PropertyValueBase dbPropValue, coreModel.Property[] properties)
        {
            if (dbPropValue == null)
            {
                throw new ArgumentNullException("dbPropValue");
            }

            var retVal = new coreModel.PropertyValue();

            retVal.InjectFrom(dbPropValue);
            retVal.LanguageCode = dbPropValue.Locale;
            retVal.PropertyName = dbPropValue.Name;
            retVal.Value        = dbPropValue.ToObjectValue();
            retVal.ValueId      = dbPropValue.KeyValue;
            retVal.ValueType    = (coreModel.PropertyValueType)dbPropValue.ValueType;

            if (properties != null)
            {
                var property = properties.FirstOrDefault(x => String.Equals(x.Name, dbPropValue.Name, StringComparison.InvariantCultureIgnoreCase));
                if (property != null)
                {
                    retVal.PropertyId = property.Id;
                }
            }
            return(retVal);
        }
        public static webModel.PropertyValue ToWebModel(this moduleModel.PropertyValue propValue)
        {
            var retVal = new webModel.PropertyValue();

            retVal.Id = propValue.Id;
            retVal.LanguageCode = propValue.LanguageCode;
            retVal.PropertyId = propValue.PropertyId;
            retVal.PropertyName = propValue.PropertyName;
            retVal.ValueId = propValue.ValueId;
            retVal.ValueType = propValue.ValueType;

            if (propValue.Property != null)
            {
                retVal.PropertyId = propValue.Property.Id;
            }
            if(propValue.ValueType == Domain.Catalog.Model.PropertyValueType.DateTime && propValue.Value != null)
            {
                retVal.Value = DateTime.SpecifyKind(((DateTime)propValue.Value), DateTimeKind.Utc).ToString("yyyy-MM-ddTHH:mm:ss.fffZ");
            }
            else
            {
                retVal.Value = (propValue.Value ?? string.Empty).ToString();
            }           

            return retVal;
        }
		public static moduleModel.PropertyValue ToModuleModel(this webModel.PropertyValue propValue)
		{
			var retVal = new moduleModel.PropertyValue();
			retVal.InjectFrom(propValue);
            retVal.Value = propValue.Value;
			retVal.ValueType = (moduleModel.PropertyValueType)(int)propValue.ValueType;
			return retVal;
		}
 public static moduleModel.PropertyValue ToCoreModel(this webModel.PropertyValue propValue)
 {
     var retVal = new moduleModel.PropertyValue();
     retVal.InjectFrom(propValue);
     retVal.Value = propValue.Value;
     retVal.ValueType = (moduleModel.PropertyValueType)(int)propValue.ValueType;
     return retVal;
 }
        public static webModel.PropertyValue ToWebModel(this moduleModel.PropertyValue propValue)
        {
            var retVal = new webModel.PropertyValue();

            retVal.InjectFrom(propValue);
            retVal.Value     = propValue.Value;
            retVal.ValueType = propValue.ValueType;

            return(retVal);
        }
        /// <summary>
        /// Converting to model type
        /// </summary>
        /// <param name="dbPropValue">The database property value.</param>
        /// <param name="properties">The properties.</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException">dbPropValue</exception>
        public static coreModel.PropertyValue ToCoreModel(this dataModel.PropertyValue dbPropValue)
        {
            if (dbPropValue == null)
                throw new ArgumentNullException("dbPropValue");

            var retVal = new coreModel.PropertyValue();
            retVal.InjectFrom(dbPropValue);
            retVal.LanguageCode = dbPropValue.Locale;
            retVal.PropertyName = dbPropValue.Name;
            retVal.Value = GetPropertyValue(dbPropValue);
            retVal.ValueId = dbPropValue.KeyValue;
            retVal.ValueType = (coreModel.PropertyValueType)dbPropValue.ValueType;
            return retVal;
        }
Beispiel #7
0
        public static webModel.PropertyValue ToWebModel(this moduleModel.PropertyValue propValue)
        {
            var retVal = new webModel.PropertyValue();

            retVal.InjectFrom(propValue);
            if (propValue.Property != null)
            {
                retVal.PropertyId = propValue.Property.Id;
            }
            retVal.Value     = (propValue.Value ?? String.Empty).ToString();
            retVal.ValueType = propValue.ValueType;

            return(retVal);
        }
        /// <summary>
        /// Converting to model type
        /// </summary>
        /// <param name="dbPropValue">The database property value.</param>
        /// <param name="properties">The properties.</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException">dbPropValue</exception>
        public static coreModel.PropertyValue ToCoreModel(this dataModel.PropertyValue dbPropValue)
        {
            if (dbPropValue == null)
            {
                throw new ArgumentNullException("dbPropValue");
            }

            var retVal = new coreModel.PropertyValue();

            retVal.InjectFrom(dbPropValue);
            retVal.LanguageCode = dbPropValue.Locale;
            retVal.PropertyName = dbPropValue.Name;
            retVal.Value        = GetPropertyValue(dbPropValue);
            retVal.ValueId      = dbPropValue.KeyValue;
            retVal.ValueType    = (coreModel.PropertyValueType)dbPropValue.ValueType;
            return(retVal);
        }
        /// <summary>
        /// Converting to foundation type
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="propValue">The property value.</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException">propValue</exception>
        public static dataModel.PropertyValue ToDataModel(this coreModel.PropertyValue propValue, PrimaryKeyResolvingMap pkMap)
        {
            if (propValue == null)
            {
                throw new ArgumentNullException("propValue");
            }

            var retVal = new dataModel.PropertyValue();

            pkMap.AddPair(propValue, retVal);
            retVal.InjectFrom(propValue);

            retVal.Name      = propValue.PropertyName;
            retVal.KeyValue  = propValue.ValueId;
            retVal.Locale    = propValue.LanguageCode;
            retVal.ValueType = (int)propValue.ValueType;
            SetPropertyValue(retVal, propValue.ValueType, propValue.Value.ToString());

            return(retVal);
        }
Beispiel #10
0
        public static webModel.PropertyValue ToWebModel(this moduleModel.PropertyValue propValue)
        {
            var retVal = new webModel.PropertyValue();

            retVal.Id           = propValue.Id;
            retVal.LanguageCode = propValue.LanguageCode;
            retVal.PropertyId   = propValue.PropertyId;
            retVal.PropertyName = propValue.PropertyName;
            retVal.ValueId      = propValue.ValueId;
            retVal.ValueType    = propValue.ValueType;

            if (propValue.Property != null)
            {
                retVal.PropertyId         = propValue.Property.Id;
                retVal.PropertyMultivalue = propValue.Property.Multivalue;
            }
            retVal.Value = propValue.Value;

            return(retVal);
        }
Beispiel #11
0
        public object Clone()
        {
            var retVal = new PropertyValue();
            retVal.Id = Id;
            retVal.CreatedBy = CreatedBy;
            retVal.CreatedDate = CreatedDate;
            retVal.ModifiedBy = ModifiedBy;
            retVal.ModifiedDate = ModifiedDate;

            retVal.PropertyId = PropertyId;
            retVal.Property = Property != null ? Property.Clone() as Property : null;
            retVal.PropertyName = PropertyName;
            retVal.Alias = Alias;
            retVal.ValueId = ValueId;
            retVal.Value = Value;
            retVal.ValueType = ValueType;
            retVal.IsInherited = IsInherited;
           
            return retVal;
        }
        /// <summary>
        /// Converting to model type
        /// </summary>
        /// <param name="dbPropValue">The database property value.</param>
        /// <param name="properties">The properties.</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException">dbPropValue</exception>
        public static coreModel.PropertyValue ToCoreModel(this dataModel.PropertyValue dbPropValue)
        {
            if (dbPropValue == null)
            {
                throw new ArgumentNullException("dbPropValue");
            }

            var retVal = new coreModel.PropertyValue();

            retVal.Alias        = dbPropValue.Alias;
            retVal.CreatedBy    = dbPropValue.CreatedBy;
            retVal.CreatedDate  = dbPropValue.CreatedDate;
            retVal.Id           = dbPropValue.Id;
            retVal.ModifiedBy   = dbPropValue.ModifiedBy;
            retVal.ModifiedDate = dbPropValue.ModifiedDate;

            retVal.LanguageCode = dbPropValue.Locale;
            retVal.PropertyName = dbPropValue.Name;
            retVal.Value        = GetPropertyValue(dbPropValue);
            retVal.ValueId      = dbPropValue.KeyValue;
            retVal.ValueType    = (coreModel.PropertyValueType)dbPropValue.ValueType;
            return(retVal);
        }
Beispiel #13
0
        /// <summary>
        /// Converting to foundation type
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="propValue">The property value.</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException">propValue</exception>
        public static dataModel.PropertyValueBase ToDataModel <T>(this coreModel.PropertyValue propValue) where T : dataModel.PropertyValueBase, new()
        {
            if (propValue == null)
            {
                throw new ArgumentNullException("propValue");
            }

            var retVal = new T();
            var id     = retVal.Id;

            retVal.InjectFrom(propValue);
            if (propValue.Id == null)
            {
                retVal.Id = id;
            }

            retVal.Name      = propValue.PropertyName;
            retVal.KeyValue  = propValue.ValueId;
            retVal.Locale    = propValue.LanguageCode;
            retVal.ValueType = (int)propValue.ValueType;
            SetPropertyValue(retVal, propValue.ValueType, propValue.Value.ToString());

            return(retVal);
        }
 /// <summary>
 /// Add property value to product
 /// </summary>
 private void AddProperty(CatalogProduct product, string propertyName, object value, PropertyValueType propertyValueType)
 {
     var property = _catalogProperties.FirstOrDefault(x => x.Name == propertyName);
     if (property != null)
     {
         var propertyValue = new PropertyValue
         {
             PropertyId = property.Id,
             PropertyName = property.Name,
             Value = value,
             ValueType = propertyValueType
         };
         if (product.PropertyValues == null)
         {
             product.PropertyValues = new List<PropertyValue>();
         }
         product.PropertyValues.Add(propertyValue);
     }
 }
Beispiel #15
0
 /// <summary>
 /// Because we not have a direct link between prop values and properties we should
 /// find property value meta information by comparing key properties like name and value type.
 /// </summary>
 /// <param name="propValue"></param>
 /// <returns></returns>
 public bool IsSuitableForValue(PropertyValue propValue)
 {
     return String.Equals(Name, propValue.PropertyName, StringComparison.InvariantCultureIgnoreCase) && ValueType == propValue.ValueType;
 }
 /// <summary>
 /// Because we not have a direct link between prop values and properties we should
 /// find property value meta information by comparing key properties like name and value type.
 /// </summary>
 /// <param name="propValue"></param>
 /// <returns></returns>
 public bool IsSuitableForValue(PropertyValue propValue)
 {
     return(String.Equals(Name, propValue.PropertyName, StringComparison.InvariantCultureIgnoreCase) && ValueType == propValue.ValueType);
 }