Esempio n. 1
0
        private void CreateRelationTypeData()
        {
            var relationType = new RelationTypeDto {
                Id = 1, Alias = Constants.Conventions.RelationTypes.RelateDocumentOnCopyAlias, ChildObjectType = Constants.ObjectTypes.Document, ParentObjectType = Constants.ObjectTypes.Document, Dual = true, Name = Constants.Conventions.RelationTypes.RelateDocumentOnCopyName
            };

            relationType.UniqueId = CreateUniqueRelationTypeId(relationType.Alias, relationType.Name);
            _database.Insert(Constants.DatabaseSchema.Tables.RelationType, "id", false, relationType);
            relationType = new RelationTypeDto {
                Id = 2, Alias = Constants.Conventions.RelationTypes.RelateParentDocumentOnDeleteAlias, ChildObjectType = Constants.ObjectTypes.Document, ParentObjectType = Constants.ObjectTypes.Document, Dual = false, Name = Constants.Conventions.RelationTypes.RelateParentDocumentOnDeleteName
            };
            relationType.UniqueId = CreateUniqueRelationTypeId(relationType.Alias, relationType.Name);
            _database.Insert(Constants.DatabaseSchema.Tables.RelationType, "id", false, relationType);
            relationType = new RelationTypeDto {
                Id = 3, Alias = Constants.Conventions.RelationTypes.RelateParentMediaFolderOnDeleteAlias, ChildObjectType = Constants.ObjectTypes.Media, ParentObjectType = Constants.ObjectTypes.Media, Dual = false, Name = Constants.Conventions.RelationTypes.RelateParentMediaFolderOnDeleteName
            };
            relationType.UniqueId = CreateUniqueRelationTypeId(relationType.Alias, relationType.Name);
            _database.Insert(Constants.DatabaseSchema.Tables.RelationType, "id", false, relationType);

            relationType = new RelationTypeDto {
                Id = 4, Alias = Constants.Conventions.RelationTypes.RelatedMediaAlias, ChildObjectType = null, ParentObjectType = null, Dual = false, Name = Constants.Conventions.RelationTypes.RelatedMediaName
            };
            relationType.UniqueId = CreateUniqueRelationTypeId(relationType.Alias, relationType.Name);
            _database.Insert(Constants.DatabaseSchema.Tables.RelationType, "id", false, relationType);

            relationType = new RelationTypeDto {
                Id = 5, Alias = Constants.Conventions.RelationTypes.RelatedDocumentAlias, ChildObjectType = null, ParentObjectType = null, Dual = false, Name = Constants.Conventions.RelationTypes.RelatedDocumentName
            };
            relationType.UniqueId = CreateUniqueRelationTypeId(relationType.Alias, relationType.Name);
            _database.Insert(Constants.DatabaseSchema.Tables.RelationType, "id", false, relationType);
        }
Esempio n. 2
0
        public static RelationTypeDto BuildDto(IRelationType entity)
        {
            var isDependency = false;

            if (entity is IRelationTypeWithIsDependency relationTypeWithIsDependency)
            {
                isDependency = relationTypeWithIsDependency.IsDependency;
            }
            var dto = new RelationTypeDto
            {
                Alias            = entity.Alias,
                ChildObjectType  = entity.ChildObjectType,
                Dual             = entity.IsBidirectional,
                IsDependency     = isDependency,
                Name             = entity.Name,
                ParentObjectType = entity.ParentObjectType,
                UniqueId         = entity.Key
            };

            if (entity.HasIdentity)
            {
                dto.Id = entity.Id;
            }

            return(dto);
        }
    private static IRelationType DtoToEntity(RelationTypeDto dto)
    {
        IRelationType entity = RelationTypeFactory.BuildEntity(dto);

        // reset dirty initial properties (U4-1946)
        ((BeingDirtyBase)entity).ResetDirtyProperties(false);

        return(entity);
    }
Esempio n. 4
0
        private static IRelationType DtoToEntity(RelationTypeDto dto, RelationTypeFactory factory)
        {
            var entity = factory.BuildEntity(dto);

            //on initial construction we don't want to have dirty properties tracked
            // http://issues.umbraco.org/issue/U4-1946
            ((TracksChangesEntityBase)entity).ResetDirtyProperties(false);

            return(entity);
        }
    protected override void PersistUpdatedItem(IRelationType entity)
    {
        entity.UpdatingEntity();

        CheckNullObjectTypeValues(entity);

        RelationTypeDto dto = RelationTypeFactory.BuildDto(entity);

        Database.Update(dto);

        entity.ResetDirtyProperties();
    }
    protected override void PersistNewItem(IRelationType entity)
    {
        entity.AddingEntity();

        CheckNullObjectTypeValues(entity);

        RelationTypeDto dto = RelationTypeFactory.BuildDto(entity);

        var id = Convert.ToInt32(Database.Insert(dto));

        entity.Id = id;

        entity.ResetDirtyProperties();
    }
        private void CreateUmbracoRelationTypeData()
        {
            var relationType = new RelationTypeDto {
                Id = 1, Alias = Constants.Conventions.RelationTypes.RelateDocumentOnCopyAlias, ChildObjectType = new Guid(Constants.ObjectTypes.Document), ParentObjectType = new Guid(Constants.ObjectTypes.Document), Dual = true, Name = Constants.Conventions.RelationTypes.RelateDocumentOnCopyName
            };

            relationType.UniqueId = (relationType.Alias + "____" + relationType.Name).ToGuid();
            _database.Insert("umbracoRelationType", "id", false, relationType);
            relationType = new RelationTypeDto {
                Id = 2, Alias = Constants.Conventions.RelationTypes.RelateParentDocumentOnDeleteAlias, ChildObjectType = new Guid(Constants.ObjectTypes.Document), ParentObjectType = new Guid(Constants.ObjectTypes.Document), Dual = false, Name = Constants.Conventions.RelationTypes.RelateParentDocumentOnDeleteName
            };
            relationType.UniqueId = (relationType.Alias + "____" + relationType.Name).ToGuid();
            _database.Insert("umbracoRelationType", "id", false, relationType);
        }
Esempio n. 8
0
        public IRelationType BuildEntity(RelationTypeDto dto)
        {
            var entity = new RelationType(dto.ChildObjectType, dto.ParentObjectType, dto.Alias)
            {
                Id = dto.Id,
                IsBidirectional = dto.Dual,
                Name            = dto.Name
            };

            //on initial construction we don't want to have dirty properties tracked
            // http://issues.umbraco.org/issue/U4-1946
            entity.ResetDirtyProperties(false);
            return(entity);
        }
Esempio n. 9
0
        public RelationTypeDto BuildDto(IRelationType entity)
        {
            var dto = new RelationTypeDto
            {
                Alias            = entity.Alias,
                ChildObjectType  = entity.ChildObjectType,
                Dual             = entity.IsBidirectional,
                Name             = entity.Name,
                ParentObjectType = entity.ParentObjectType
            };

            if (entity.HasIdentity)
            {
                dto.Id = entity.Id;
            }

            return(dto);
        }
Esempio n. 10
0
        public static IRelationType BuildEntity(RelationTypeDto dto)
        {
            var entity = new RelationType(dto.Name, dto.Alias, dto.Dual, dto.ParentObjectType, dto.ChildObjectType);

            try
            {
                entity.DisableChangeTracking();

                entity.Id  = dto.Id;
                entity.Key = dto.UniqueId;

                // reset dirty initial properties (U4-1946)
                entity.ResetDirtyProperties(false);
                return(entity);
            }
            finally
            {
                entity.EnableChangeTracking();
            }
        }
        public IRelationType BuildEntity(RelationTypeDto dto)
        {
            var entity = new RelationType(dto.ChildObjectType, dto.ParentObjectType, dto.Alias);

            try
            {
                entity.DisableChangeTracking();

                entity.Id              = dto.Id;
                entity.Key             = dto.UniqueId;
                entity.IsBidirectional = dto.Dual;
                entity.Name            = dto.Name;

                //on initial construction we don't want to have dirty properties tracked
                // http://issues.umbraco.org/issue/U4-1946
                entity.ResetDirtyProperties(false);
                return(entity);
            }
            finally
            {
                entity.EnableChangeTracking();
            }
        }