public virtual DynamicContentItem ToModel(DynamicContentItem item)
        {
            if (item == null)
            {
                throw new ArgumentNullException(nameof(item));
            }

            item.Id           = Id;
            item.CreatedBy    = CreatedBy;
            item.CreatedDate  = CreatedDate;
            item.ModifiedBy   = ModifiedBy;
            item.ModifiedDate = ModifiedDate;

            item.Name        = Name;
            item.FolderId    = FolderId;
            item.ImageUrl    = ImageUrl;
            item.ContentType = ContentTypeId;
            item.Description = Description;

            if (Folder != null)
            {
                item.Folder = Folder.ToModel(AbstractTypeFactory <DynamicContentFolder> .TryCreateInstance());
            }

            item.DynamicProperties = DynamicPropertyObjectValues.GroupBy(g => g.PropertyId).Select(x =>
            {
                var property    = AbstractTypeFactory <DynamicObjectProperty> .TryCreateInstance();
                property.Id     = x.Key;
                property.Name   = x.FirstOrDefault()?.PropertyName;
                property.Values = x.Select(v => v.ToModel(AbstractTypeFactory <DynamicPropertyObjectValue> .TryCreateInstance())).ToArray();
                return(property);
            }).ToArray();

            return(item);
        }
        public virtual DynamicContentItemEntity FromModel(DynamicContentItem item, PrimaryKeyResolvingMap pkMap)
        {
            if (item == null)
            {
                throw new ArgumentNullException(nameof(item));
            }

            pkMap.AddPair(item, this);

            Id           = item.Id;
            CreatedBy    = item.CreatedBy;
            CreatedDate  = item.CreatedDate;
            ModifiedBy   = item.ModifiedBy;
            ModifiedDate = item.ModifiedDate;

            Name          = item.Name;
            FolderId      = item.FolderId;
            ImageUrl      = item.ImageUrl;
            ContentTypeId = item.ContentType;
            Description   = item.Description;

            if (item.DynamicProperties != null)
            {
                ContentTypeId = item.GetDynamicPropertyValue <string>("Content type", null);
                DynamicPropertyObjectValues = new ObservableCollection <DynamicContentItemDynamicPropertyObjectValueEntity>(item.DynamicProperties.SelectMany(p => p.Values
                                                                                                                                                              .Select(v => AbstractTypeFactory <DynamicContentItemDynamicPropertyObjectValueEntity> .TryCreateInstance().FromModel(v, item, p))).OfType <DynamicContentItemDynamicPropertyObjectValueEntity>());
            }

            return(this);
        }
Beispiel #3
0
        public virtual DynamicContentItemEntity FromModel(DynamicContentItem item, PrimaryKeyResolvingMap pkMap)
        {
            if (item == null)
            {
                throw new NullReferenceException(nameof(item));
            }

            pkMap.AddPair(item, this);

            Id            = item.Id;
            CreatedBy     = item.CreatedBy;
            CreatedDate   = item.CreatedDate;
            Description   = item.Description;
            ModifiedBy    = item.ModifiedBy;
            ModifiedDate  = item.ModifiedDate;
            Name          = item.Name;
            FolderId      = item.FolderId;
            ImageUrl      = item.ImageUrl;
            ContentTypeId = item.ContentType;

            if (item.DynamicProperties != null)
            {
                ContentTypeId = item.GetDynamicPropertyValue <string>("Content type", null);
            }

            return(this);
        }
Beispiel #4
0
        /// <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);

            target.InjectFrom(patchInjection, source);
        }
Beispiel #5
0
        public void Test()
        {
            var repository  = new MarketingRepositoryImpl("VirtoCommerce", new EntityPrimaryKeyGeneratorInterceptor(), new AuditableInterceptor());
            var contentItem = new dataModel.DynamicContentItem()
            {
                Name = "ss",
            };

            repository.Add(contentItem);
            repository.UnitOfWork.Commit();
        }
        public void Can_create_marketing_contentitem()
        {
            var repository  = this.GetRepository();
            var contentItem = new dataModel.DynamicContentItem()
            {
                Name = "ss",
            };

            repository.Add(contentItem);
            repository.UnitOfWork.Commit();
        }
        public void Can_create_marketing_contentitem()
		{
			var repository = this.GetRepository();
			var contentItem = new dataModel.DynamicContentItem()
			{
				Name = "ss",
			};
	
			repository.Add(contentItem);
			repository.UnitOfWork.Commit();
		}
		public void Test()
		{
			var repository = new MarketingRepositoryImpl("VirtoCommerce", new EntityPrimaryKeyGeneratorInterceptor(), new AuditableInterceptor());
			var contentItem = new dataModel.DynamicContentItem()
			{
				Name = "ss",
			};
	
			repository.Add(contentItem);
			repository.UnitOfWork.Commit();

		}
		public static dataModel.DynamicContentItem ToDataModel(this coreModel.DynamicContentItem contentItem)
		{
			if (contentItem == null)
				throw new ArgumentNullException("contentItem");

			var retVal = new dataModel.DynamicContentItem();
			retVal.InjectFrom(contentItem);
			retVal.ContentTypeId = contentItem.ContentType;
		
		
			return retVal;
		}
Beispiel #10
0
        public virtual DynamicContentItem ToModel(DynamicContentItem contentItem)
        {
            if (contentItem == null)
            {
                throw new ArgumentNullException(nameof(contentItem));
            }

            ContentItem.ToModel(contentItem);

            contentItem.Priority = Priority;

            return(contentItem);
        }
		public static dataModel.DynamicContentItem ToDataModel(this coreModel.DynamicContentItem contentItem, PrimaryKeyResolvingMap pkMap)
		{
			if (contentItem == null)
				throw new ArgumentNullException("contentItem");

			var retVal = new dataModel.DynamicContentItem();
            pkMap.AddPair(contentItem, retVal);
            retVal.InjectFrom(contentItem);
			retVal.ContentTypeId = contentItem.ContentType;
		
		
			return retVal;
		}
Beispiel #12
0
        public virtual PublishingGroupContentItemEntity FromModel(DynamicContentItem contentItem, PrimaryKeyResolvingMap pkMap)
        {
            if (contentItem == null)
            {
                throw new ArgumentNullException(nameof(contentItem));
            }

            pkMap.AddPair(contentItem, this);

            DynamicContentItemId = contentItem.Id;
            Priority             = contentItem.Priority;

            return(this);
        }
Beispiel #13
0
        public static dataModel.DynamicContentItem ToDataModel(this coreModel.DynamicContentItem contentItem)
        {
            if (contentItem == null)
            {
                throw new ArgumentNullException("contentItem");
            }

            var retVal = new dataModel.DynamicContentItem();

            retVal.InjectFrom(contentItem);
            retVal.ContentTypeId = contentItem.ContentType;


            return(retVal);
        }
Beispiel #14
0
        public static dataModel.DynamicContentItem ToDataModel(this coreModel.DynamicContentItem contentItem, PrimaryKeyResolvingMap pkMap)
        {
            if (contentItem == null)
            {
                throw new ArgumentNullException("contentItem");
            }

            var retVal = new dataModel.DynamicContentItem();

            pkMap.AddPair(contentItem, retVal);
            retVal.InjectFrom(contentItem);
            retVal.ContentTypeId = contentItem.ContentType;


            return(retVal);
        }
Beispiel #15
0
        /// <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);
        }
Beispiel #16
0
        /// <summary>
        /// Converting to model type
        /// </summary>
        /// <param name="catalogBase"></param>
        /// <returns></returns>
        public static coreModel.DynamicContentItem ToCoreModel(this dataModel.DynamicContentItem dbEntity)
        {
            if (dbEntity == null)
            {
                throw new ArgumentNullException("dbEntity");
            }

            var retVal = new coreModel.DynamicContentItem();

            retVal.InjectFrom(dbEntity);

            retVal.ContentType = dbEntity.ContentTypeId;

            if (dbEntity.Folder != null)
            {
                retVal.Folder = dbEntity.Folder.ToCoreModel();
            }

            return(retVal);
        }
		public static dataModel.DynamicContentItem ToDataModel(this coreModel.DynamicContentItem contentItem)
		{
			if (contentItem == null)
				throw new ArgumentNullException("contentItem");

			var retVal = new dataModel.DynamicContentItem();
			retVal.InjectFrom(contentItem);
			retVal.ContentTypeId = contentItem.ContentType;
		
			retVal.PropertyValues = new NullCollection<dataModel.DynamicContentItemProperty>();
			if(contentItem.Properties != null)
			{
				retVal.PropertyValues = new ObservableCollection<dataModel.DynamicContentItemProperty>(contentItem.Properties.Select(x => x.ToDataModel()));
				foreach (var property in retVal.PropertyValues)
				{
					property.DynamicContentItemId = retVal.Id;
				}
			}
			return retVal;
		}
Beispiel #18
0
        public virtual DynamicContentItemEntity FromModel(DynamicContentItem item, PrimaryKeyResolvingMap pkMap)
        {
            if (item == null)
            {
                throw new NullReferenceException(nameof(item));
            }

            pkMap.AddPair(item, this);

            this.Id            = item.Id;
            this.CreatedBy     = item.CreatedBy;
            this.CreatedDate   = item.CreatedDate;
            this.Description   = item.Description;
            this.ModifiedBy    = item.ModifiedBy;
            this.ModifiedDate  = item.ModifiedDate;
            this.Name          = item.Name;
            this.FolderId      = item.FolderId;
            this.ImageUrl      = item.ImageUrl;
            this.ContentTypeId = item.ContentType;

            return(this);
        }
Beispiel #19
0
        public static dataModel.DynamicContentItem ToDataModel(this coreModel.DynamicContentItem contentItem)
        {
            if (contentItem == null)
            {
                throw new ArgumentNullException("contentItem");
            }

            var retVal = new dataModel.DynamicContentItem();

            retVal.InjectFrom(contentItem);
            retVal.ContentTypeId = contentItem.ContentType;

            retVal.PropertyValues = new NullCollection <dataModel.DynamicContentItemProperty>();
            if (contentItem.Properties != null)
            {
                retVal.PropertyValues = new ObservableCollection <dataModel.DynamicContentItemProperty>(contentItem.Properties.Select(x => x.ToDataModel()));
                foreach (var property in retVal.PropertyValues)
                {
                    property.DynamicContentItemId = retVal.Id;
                }
            }
            return(retVal);
        }
Beispiel #20
0
        public virtual DynamicContentItem ToModel(DynamicContentItem item)
        {
            if (item == null)
            {
                throw new NullReferenceException(nameof(item));
            }

            item.Id           = this.Id;
            item.CreatedBy    = this.CreatedBy;
            item.CreatedDate  = this.CreatedDate;
            item.Description  = this.Description;
            item.ModifiedBy   = this.ModifiedBy;
            item.ModifiedDate = this.ModifiedDate;
            item.Name         = this.Name;
            item.FolderId     = this.FolderId;
            item.ImageUrl     = this.ImageUrl;
            item.ContentType  = this.ContentTypeId;

            if (this.Folder != null)
            {
                item.Folder = this.Folder.ToModel(AbstractTypeFactory <DynamicContentFolder> .TryCreateInstance());
            }
            return(item);
        }