public static dataModel.DynamicContentPublishingGroup ToDataModel(this coreModel.DynamicContentPublication publication) { if (publication == null) { throw new ArgumentNullException("publication"); } var retVal = new dataModel.DynamicContentPublishingGroup(); retVal.InjectFrom(publication); retVal.ConditionExpression = publication.PredicateSerialized; retVal.PredicateVisualTreeSerialized = publication.PredicateVisualTreeSerialized; if (publication.ContentItems != null) { retVal.ContentItems = new ObservableCollection <dataModel.PublishingGroupContentItem>(publication.ContentItems.Select(x => new dataModel.PublishingGroupContentItem { DynamicContentPublishingGroupId = retVal.Id, DynamicContentItemId = x.Id })); } if (publication.ContentPlaces != null) { retVal.ContentPlaces = new ObservableCollection <dataModel.PublishingGroupContentPlace>(publication.ContentPlaces.Select(x => new dataModel.PublishingGroupContentPlace { DynamicContentPublishingGroupId = retVal.Id, DynamicContentPlaceId = x.Id })); } return(retVal); }
public static dataModel.DynamicContentPublishingGroup ToDataModel(this coreModel.DynamicContentPublication publication) { if (publication == null) throw new ArgumentNullException("publication"); var retVal = new dataModel.DynamicContentPublishingGroup(); retVal.InjectFrom(publication); retVal.ConditionExpression = publication.PredicateSerialized; retVal.PredicateVisualTreeSerialized = publication.PredicateVisualTreeSerialized; if (publication.ContentItems != null) { retVal.ContentItems = new ObservableCollection<dataModel.PublishingGroupContentItem>(publication.ContentItems.Select(x => new dataModel.PublishingGroupContentItem { DynamicContentPublishingGroupId = retVal.Id, DynamicContentItemId = x.Id })); } if (publication.ContentPlaces != null) { retVal.ContentPlaces = new ObservableCollection<dataModel.PublishingGroupContentPlace>(publication.ContentPlaces.Select(x => new dataModel.PublishingGroupContentPlace { DynamicContentPublishingGroupId = retVal.Id, DynamicContentPlaceId = x.Id })); } return retVal; }
/// <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.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) => { }); } }