/// <summary> /// Patch CatalogLanguage type /// </summary> /// <param name="source"></param> /// <param name="target"></param> public static void Patch(this dataModel.PropertyValue source, dataModel.PropertyValue target) { if (target == null) { throw new ArgumentNullException("target"); } var newValue = source.ToString(); if (newValue != null) { SetPropertyValue(target, (coreModel.PropertyValueType)target.ValueType, newValue); } if (source.Alias != null) { target.Alias = source.Alias; } if (source.KeyValue != null) { target.KeyValue = source.KeyValue; } if (source.Alias != null) { target.Alias = source.Alias; } }
private static void SetPropertyValue(dataModel.PropertyValue retVal, coreModel.PropertyValueType type, string value) { switch (type) { case coreModel.PropertyValueType.LongText: retVal.LongTextValue = value; break; case coreModel.PropertyValueType.ShortText: retVal.ShortTextValue = value; break; case coreModel.PropertyValueType.Number: decimal parsedDecimal; Decimal.TryParse(value.Replace(',', '.'), NumberStyles.Any, CultureInfo.InvariantCulture, out parsedDecimal); retVal.DecimalValue = parsedDecimal; break; case coreModel.PropertyValueType.DateTime: retVal.DateTimeValue = DateTime.Parse(value); break; case coreModel.PropertyValueType.Boolean: retVal.BooleanValue = Boolean.Parse(value); break; } }
/// <summary> /// Patch changes /// </summary> /// <param name="source"></param> /// <param name="target"></param> public static void Patch(this dataModel.PropertyValue source, dataModel.PropertyValue target) { if (target == null) { throw new ArgumentNullException("target"); } var patchInjectionPolicy = new PatchInjection <dataModel.PropertyValue>(x => x.BooleanValue, x => x.DateTimeValue, x => x.DecimalValue, x => x.IntegerValue, x => x.KeyValue, x => x.LongTextValue, x => x.ShortTextValue); target.InjectFrom(patchInjectionPolicy, source); }
/// <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; }
/// <summary> /// Converting to foundation type /// </summary> /// <param name="catalog"></param> /// <returns></returns> public static dataModel.PropertyValue ToDataModel(this coreModel.PropertyDictionaryValue propDictValue, coreModel.Property property) { var retVal = new dataModel.PropertyValue { Locale = propDictValue.LanguageCode, PropertyId = property.Id }; retVal.InjectFrom(propDictValue); if(propDictValue.Id != null) { retVal.Id = propDictValue.Id; } SetPropertyValue(retVal, property.ValueType, propDictValue.Value); return retVal; }
/// <summary> /// Converting to foundation type /// </summary> /// <param name="catalog"></param> /// <returns></returns> public static dataModel.PropertyValue ToDataModel(this coreModel.PropertyDictionaryValue propDictValue, coreModel.Property property) { var retVal = new dataModel.PropertyValue { Locale = propDictValue.LanguageCode, PropertyId = property.Id }; retVal.InjectFrom(propDictValue); if (propDictValue.Id != null) { retVal.Id = propDictValue.Id; } SetPropertyValue(retVal, property.ValueType, propDictValue.Value); return(retVal); }
/// <summary> /// Converting to model type /// </summary> /// <param name="catalogBase"></param> /// <returns></returns> public static coreModel.PropertyDictionaryValue ToCoreModel(this dataModel.PropertyValue dbPropValue, coreModel.Property property) { if (property == null) { throw new ArgumentNullException("property"); } var retVal = new coreModel.PropertyDictionaryValue(); retVal.InjectFrom(dbPropValue); retVal.LanguageCode = dbPropValue.Locale; retVal.Value = dbPropValue.ToString(); retVal.PropertyId = property.Id; retVal.Property = property; return(retVal); }
private static object GetPropertyValue(dataModel.PropertyValue propertyValue) { switch (propertyValue.ValueType) { case (int)coreModel.PropertyValueType.Boolean: return(propertyValue.BooleanValue); case (int)coreModel.PropertyValueType.DateTime: return(propertyValue.DateTimeValue); case (int)coreModel.PropertyValueType.Number: return(propertyValue.DecimalValue); case (int)coreModel.PropertyValueType.LongText: return(propertyValue.LongTextValue); default: return(propertyValue.ShortTextValue); } }
/// <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); }
/// <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); }