private static object GetPropertyValue(dataModel.DynamicContentItemProperty propValue) { object retVal = null; switch ((coreModel.PropertyValueType)propValue.ValueType) { case coreModel.PropertyValueType.Boolean: retVal = propValue.BooleanValue; break; case coreModel.PropertyValueType.DateTime: retVal = propValue.DateTimeValue; break; case coreModel.PropertyValueType.Decimal: retVal = propValue.DecimalValue; break; case coreModel.PropertyValueType.Integer: retVal = propValue.IntegerValue; break; case coreModel.PropertyValueType.LongText: retVal = propValue.LongTextValue; break; case coreModel.PropertyValueType.ShortText: retVal = propValue.ShortTextValue; break; } return retVal; }
/// <summary> /// Patch /// </summary> /// <param name="source"></param> /// <param name="target"></param> public static void Patch(this dataModel.DynamicContentItemProperty source, dataModel.DynamicContentItemProperty target) { var patchInjectionPolicy = new PatchInjection<dataModel.DynamicContentItemProperty>(x => x.BooleanValue, x => x.DateTimeValue, x => x.DecimalValue, x => x.IntegerValue, x => x.ShortTextValue, x => x.LongTextValue, x => x.ValueType); target.InjectFrom(patchInjectionPolicy, source); }
/// <summary> /// Patch changes /// </summary> /// <param name="source"></param> /// <param name="target"></param> public static void Patch(this dataModel.DynamicContentFolder source, dataModel.DynamicContentFolder target) { if (target == null) throw new ArgumentNullException("target"); var patchInjection = new PatchInjection<dataModel.DynamicContentFolder>(x => x.Name, x => x.Description, x => x.ImageUrl); target.InjectFrom(patchInjection, source); }
/// <summary> /// Patch changes /// </summary> /// <param name="source"></param> /// <param name="target"></param> public static void Patch(this dataModel.DynamicContentItem source, dataModel.DynamicContentItem target) { if (target == null) throw new ArgumentNullException("target"); var patchInjection = new PatchInjection<dataModel.DynamicContentItem>(x => x.Name, x => x.Description, x=>x.FolderId, x=>x.ImageUrl, x=>x.ContentTypeId); if (!source.PropertyValues.IsNullCollection()) { var propertyComparer = AnonymousComparer.Create((dataModel.DynamicContentItemProperty x) => x.Name); source.PropertyValues.Patch(target.PropertyValues, propertyComparer, (sourceProperty, targetProperty) => sourceProperty.Patch(targetProperty)); } target.InjectFrom(patchInjection, source); }
/// <summary> /// Patch changes /// </summary> /// <param name="source"></param> /// <param name="target"></param> public static void Patch(this dataModel.Promotion source, dataModel.Promotion target) { if (target == null) throw new ArgumentNullException("target"); var patchInjection = new PatchInjection<dataModel.Promotion>(x => x.Name, x => x.Description, x=>x.Priority, x=>x.CouponCode, x=>x.StoreId, x => x.StartDate, x => x.EndDate, x => x.IsActive, x => x.TotalLimit, x => x.PerCustomerLimit, x => x.PredicateSerialized, x => x.PredicateVisualTreeSerialized, x => x.RewardsSerialized); target.InjectFrom(patchInjection, source); if (!source.Coupons.IsNullCollection()) { var couponComparer = AnonymousComparer.Create((dataModel.Coupon x) => x.Code); source.Coupons.Patch(target.Coupons, (sourceCoupon, targetCoupon) => { return; }); } }
/// <summary> /// Patch changes /// </summary> /// <param name="source"></param> /// <param name="target"></param> public static void Patch(this dataModel.DynamicContentPublishingGroup source, dataModel.DynamicContentPublishingGroup target) { if (target == null) throw new ArgumentNullException("target"); var patchInjection = new PatchInjection<dataModel.DynamicContentPublishingGroup>(x=> x.StoreId, x => x.Name, x => x.Description, x => x.IsActive, x => x.StartDate, x => x.EndDate, x=>x.PredicateVisualTreeSerialized, x=>x.ConditionExpression); target.InjectFrom(patchInjection, source); if (!source.ContentItems.IsNullCollection()) { var itemComparer = AnonymousComparer.Create((dataModel.PublishingGroupContentItem x) => x.DynamicContentItemId); source.ContentItems.Patch(target.ContentItems, itemComparer, (sourceProperty, targetProperty) => { }); } if (!source.ContentPlaces.IsNullCollection()) { var itemComparer = AnonymousComparer.Create((dataModel.PublishingGroupContentPlace x) => x.DynamicContentPlaceId); source.ContentPlaces.Patch(target.ContentPlaces, itemComparer, (sourceProperty, targetProperty) => { }); } }
private static void SetPropertyValue(dataModel.DynamicContentItemProperty retVal, coreModel.Property property) { switch (property.ValueType) { case coreModel.PropertyValueType.Boolean: retVal.BooleanValue = Convert.ToBoolean(property.Value); break; case coreModel.PropertyValueType.DateTime: retVal.DateTimeValue = Convert.ToDateTime(property.Value); break; case coreModel.PropertyValueType.Decimal: retVal.DecimalValue = Convert.ToDecimal(property.Value); break; case coreModel.PropertyValueType.Integer: retVal.IntegerValue = Convert.ToInt32(property.Value); break; case coreModel.PropertyValueType.LongText: retVal.LongTextValue = Convert.ToString(property.Value); break; case coreModel.PropertyValueType.ShortText: retVal.ShortTextValue = Convert.ToString(property.Value); break; } }