public virtual DynamicContentPublication ToModel(DynamicContentPublication publication) { if (publication == null) { throw new NullReferenceException(nameof(publication)); } publication.Id = Id; publication.CreatedBy = CreatedBy; publication.CreatedDate = CreatedDate; publication.Description = Description; publication.ModifiedBy = ModifiedBy; publication.ModifiedDate = ModifiedDate; publication.Name = Name; publication.Priority = Priority; publication.IsActive = IsActive; publication.StoreId = StoreId; publication.StartDate = StartDate; publication.EndDate = EndDate; publication.PredicateSerialized = ConditionExpression; publication.PredicateVisualTreeSerialized = PredicateVisualTreeSerialized; if (ContentItems != null) { //TODO publication.ContentItems = ContentItems.Where(ci => ci.ContentItem != null).Select(x => x.ContentItem.ToModel(AbstractTypeFactory <DynamicContentItem> .TryCreateInstance())).ToList(); } if (ContentPlaces != null) { //TODO publication.ContentPlaces = ContentPlaces.Where(ci => ci.ContentPlace != null).Select(x => x.ContentPlace.ToModel(AbstractTypeFactory <DynamicContentPlace> .TryCreateInstance())).ToList(); } return(publication); }
public virtual DynamicContentPublishingGroupEntity FromModel(DynamicContentPublication publication, PrimaryKeyResolvingMap pkMap) { if (publication == null) { throw new ArgumentNullException(nameof(publication)); } pkMap.AddPair(publication, this); Id = publication.Id; CreatedBy = publication.CreatedBy; CreatedDate = publication.CreatedDate; ModifiedBy = publication.ModifiedBy; ModifiedDate = publication.ModifiedDate; OuterId = publication.OuterId; Name = publication.Name; Priority = publication.Priority; IsActive = publication.IsActive; StoreId = publication.StoreId; StartDate = publication.StartDate; EndDate = publication.EndDate; Description = publication.Description; if (publication.ContentItems != null) { ContentItems = new ObservableCollection <PublishingGroupContentItemEntity>(publication.ContentItems.Select( x => { var result = AbstractTypeFactory <PublishingGroupContentItemEntity> .TryCreateInstance().FromModel(x, pkMap); result.DynamicContentPublishingGroupId = Id; return(result); })); } if (publication.ContentPlaces != null) { ContentPlaces = new ObservableCollection <PublishingGroupContentPlaceEntity>(publication.ContentPlaces.Select( x => { var result = AbstractTypeFactory <PublishingGroupContentPlaceEntity> .TryCreateInstance().FromModel(x, pkMap); result.DynamicContentPublishingGroupId = Id; return(result); })); } if (publication.DynamicExpression != null) { PredicateVisualTreeSerialized = JsonConvert.SerializeObject(publication.DynamicExpression, new ConditionJsonConverter(doNotSerializeAvailCondition: true)); } return(this); }
private void SerializeDynamicContentPublicationConditions(DynamicContentPublication publication) { //Serialize condition expression if (publication.DynamicExpression?.Children != null) { var conditionExpression = ((DynamicContentConditionTree)publication.DynamicExpression).GetConditions(); publication.PredicateSerialized = JsonConvert.SerializeObject(conditionExpression); //Clear availableElements in expression (for decrease size) publication.DynamicExpression.AvailableChildren = null; var allBlocks = publication.DynamicExpression.Traverse(x => x.Children); foreach (var block in allBlocks) { block.AvailableChildren = null; } publication.PredicateVisualTreeSerialized = JsonConvert.SerializeObject(publication.DynamicExpression); } }
public virtual DynamicContentPublication ToModel(DynamicContentPublication publication) { if (publication == null) { throw new NullReferenceException(nameof(publication)); } publication.Id = this.Id; publication.CreatedBy = this.CreatedBy; publication.CreatedDate = this.CreatedDate; publication.Description = this.Description; publication.ModifiedBy = this.ModifiedBy; publication.ModifiedDate = this.ModifiedDate; publication.Name = this.Name; publication.Priority = this.Priority; publication.IsActive = this.IsActive; publication.StoreId = this.StoreId; publication.StartDate = this.StartDate; publication.EndDate = this.EndDate; publication.PredicateSerialized = this.ConditionExpression; publication.PredicateVisualTreeSerialized = this.PredicateVisualTreeSerialized; if (!string.IsNullOrEmpty(publication.PredicateVisualTreeSerialized)) { //Temporary back data compatibility fix for serialized expressions publication.PredicateVisualTreeSerialized = publication.PredicateVisualTreeSerialized.Replace("VirtoCommerce.DynamicExpressionModule.", "VirtoCommerce.DynamicExpressionsModule."); } if (!string.IsNullOrEmpty(publication.PredicateSerialized)) { //Temporary back data compatibility fix for serialized expressions publication.PredicateSerialized = publication.PredicateSerialized.Replace("VirtoCommerce.DynamicExpressionModule.", "VirtoCommerce.DynamicExpressionsModule."); } if (this.ContentItems != null) { publication.ContentItems = this.ContentItems.Select(x => x.ContentItem.ToModel(AbstractTypeFactory <DynamicContentItem> .TryCreateInstance())).ToList(); } if (this.ContentPlaces != null) { publication.ContentPlaces = this.ContentPlaces.Select(x => x.ContentPlace.ToModel(AbstractTypeFactory <DynamicContentPlace> .TryCreateInstance())).ToList(); } return(publication); }
public virtual DynamicContentPublication ToModel(DynamicContentPublication publication) { if (publication == null) { throw new ArgumentNullException(nameof(publication)); } publication.Id = Id; publication.CreatedBy = CreatedBy; publication.CreatedDate = CreatedDate; publication.ModifiedBy = ModifiedBy; publication.ModifiedDate = ModifiedDate; publication.OuterId = OuterId; publication.Name = Name; publication.Priority = Priority; publication.IsActive = IsActive; publication.StoreId = StoreId; publication.StartDate = StartDate; publication.EndDate = EndDate; publication.Description = Description; if (ContentItems != null) { publication.ContentItems = ContentItems.Select(x => x.ToModel(AbstractTypeFactory <DynamicContentItem> .TryCreateInstance())).ToList(); } if (ContentPlaces != null) { //TODO publication.ContentPlaces = ContentPlaces.Where(ci => ci.ContentPlace != null).Select(x => x.ContentPlace.ToModel(AbstractTypeFactory <DynamicContentPlace> .TryCreateInstance())).ToList(); } publication.DynamicExpression = AbstractTypeFactory <DynamicContentConditionTree> .TryCreateInstance(); if (PredicateVisualTreeSerialized != null) { publication.DynamicExpression = JsonConvert.DeserializeObject <DynamicContentConditionTree>(PredicateVisualTreeSerialized, new ConditionJsonConverter()); } return(publication); }
public virtual DynamicContentPublishingGroupEntity FromModel(DynamicContentPublication publication, PrimaryKeyResolvingMap pkMap) { if (publication == null) { throw new NullReferenceException(nameof(publication)); } pkMap.AddPair(publication, this); this.Id = publication.Id; this.CreatedBy = publication.CreatedBy; this.CreatedDate = publication.CreatedDate; this.Description = publication.Description; this.ModifiedBy = publication.ModifiedBy; this.ModifiedDate = publication.ModifiedDate; this.Name = publication.Name; this.Priority = publication.Priority; this.IsActive = publication.IsActive; this.StoreId = publication.StoreId; this.StartDate = publication.StartDate; this.EndDate = publication.EndDate; this.ConditionExpression = publication.PredicateSerialized; this.PredicateVisualTreeSerialized = publication.PredicateVisualTreeSerialized; if (publication.ContentItems != null) { this.ContentItems = new ObservableCollection <PublishingGroupContentItemEntity>(publication.ContentItems.Select(x => new PublishingGroupContentItemEntity { DynamicContentPublishingGroupId = this.Id, DynamicContentItemId = x.Id })); } if (publication.ContentPlaces != null) { this.ContentPlaces = new ObservableCollection <PublishingGroupContentPlaceEntity>(publication.ContentPlaces.Select(x => new PublishingGroupContentPlaceEntity { DynamicContentPublishingGroupId = this.Id, DynamicContentPlaceId = x.Id })); } return(this); }