Example #1
0
        private int CopyObject(BllObject sourceObj)
        {
            var tempObj = ObjectRepository.GetObjectPropertiesById(sourceObj.Id);

            tempObj.Id       = 0;
            tempObj.PageId   = DestinationId;
            tempObj.LockedBy = 0;
            var newObj = DefaultRepository.Save <BllObject, ObjectDAL>(tempObj);

            if (sourceObj.IsObjectContainerType)
            {
                CopyContainer(newObj.Id, sourceObj.Container);
                CopyContainerStatuses(newObj.Id, sourceObj.Id);
            }
            else if (sourceObj.IsObjectFormType)
            {
                CopyContentForm(newObj.Id, sourceObj.ContentForm);
            }
            var formats        = ObjectFormatRepository.GetFormatsByObjectId(sourceObj.Id);
            var newDefFormatId = CopyObjectFormats(newObj.Id, sourceObj);

            if (newDefFormatId != 0)
            {
                ObjectRepository.UpdateDefaultFormatId(newObj.Id, newDefFormatId);
            }

            CopyObjectValues(newObj.Id, sourceObj);

            return(newObj.Id);
        }
Example #2
0
        Field IFieldRepository.CreateNew(Field item, bool explicitOrder)
        {
            try
            {
                if (explicitOrder)
                {
                    ChangeMaxOrderTriggerState(false);
                    item.ReorderContentFields();
                }

                var constraint   = item.Constraint;
                var dynamicImage = item.DynamicImage;

                DefaultRepository.TurnIdentityInsertOn(EntityTypeCode.Field, item);
                var newItem = DefaultRepository.Save <Field, FieldDAL>(item);
                DefaultRepository.TurnIdentityInsertOff(EntityTypeCode.Field);

                if (explicitOrder)
                {
                    UpdateFieldOrder(newItem.Id, item.Order);
                }

                SaveConstraint(constraint, newItem);
                SaveDynamicImage(dynamicImage, newItem);

                return(GetById(newItem.Id));
            }
            finally
            {
                if (explicitOrder)
                {
                    ChangeMaxOrderTriggerState(true);
                }
            }
        }
Example #3
0
        Field IFieldRepository.CreateNew(Field item, bool explicitOrder)
        {
            using (var scope = new QPConnectionScope())
            {
                try
                {
                    if (QPContext.DatabaseType == DatabaseType.SqlServer)
                    {
                        ChangeMaxOrderTriggerState(scope.DbConnection, false);
                        ChangeInsertFieldTriggerState(scope.DbConnection, false);
                        ChangeM2MDefaultTriggerState(scope.DbConnection, false);
                    }

                    if (explicitOrder)
                    {
                        item.ReorderContentFields();
                    }
                    else
                    {
                        var fieldsExists = QPContext.EFContext.FieldSet.Any(n => n.ContentId == item.ContentId);
                        var maxOrder     = fieldsExists ?
                                           (int)QPContext.EFContext.FieldSet.Where(n => n.ContentId == item.ContentId)
                                           .Select(n => n.Order).Max() : 0;
                        item.Order = maxOrder + 1;
                    }

                    var constraint   = item.Constraint;
                    var dynamicImage = item.DynamicImage;
                    var fieldValues  = item.QpPluginFieldValues;

                    DefaultRepository.TurnIdentityInsertOn(EntityTypeCode.Field, item);
                    var newItem = DefaultRepository.Save <Field, FieldDAL>(item);
                    var field   = GetDal(newItem);
                    Common.AddColumn(scope.DbConnection, field);

                    DefaultRepository.TurnIdentityInsertOff(EntityTypeCode.Field);

                    SaveConstraint(constraint, newItem);
                    SaveDynamicImage(dynamicImage, newItem);
                    UpdatePluginValues(fieldValues, newItem.Id);

                    return(GetById(newItem.Id));
                }
                finally
                {
                    if (QPContext.DatabaseType == DatabaseType.SqlServer)
                    {
                        ChangeMaxOrderTriggerState(scope.DbConnection, true);
                        ChangeInsertFieldTriggerState(scope.DbConnection, true);
                        ChangeM2MDefaultTriggerState(scope.DbConnection, true);
                    }
                }
            }
        }
Example #4
0
        internal static Content Save(Content content, bool createDefaultField)
        {
            var binding = content.WorkflowBinding;

            FieldRepository.ChangeCreateFieldsTriggerState(false);
            DefaultRepository.TurnIdentityInsertOn(EntityTypeCode.Content, content);

            var newContent = DefaultRepository.Save <Content, ContentDAL>(content);

            DefaultRepository.TurnIdentityInsertOff(EntityTypeCode.Content);
            FieldRepository.ChangeCreateFieldsTriggerState(true);

            if (createDefaultField)
            {
                CreateDefaultField(newContent, content.ForceFieldIds);
            }

            binding.SetContent(newContent);
            WorkflowRepository.UpdateContentWorkflowBind(binding);
            return(GetById(newContent.Id));
        }
 public EntityPermission Save(EntityPermission permission) => DefaultRepository.Save <EntityPermission, ContentPermissionDAL>(permission);
Example #6
0
 public EntityPermission Save(EntityPermission permission) => DefaultRepository.Save <EntityPermission, WorkflowPermissionDAL>(permission);
 public EntityPermission Save(EntityPermission permission) => DefaultRepository.Save <EntityPermission, SiteFolderPermissionDAL>(permission);
Example #8
0
 public EntityPermission Save(EntityPermission permission) => DefaultRepository.Save <EntityPermission, ArticlePermissionDAL>(permission);
Example #9
0
 public EntityPermission Save(EntityPermission permission) => DefaultRepository.Save <EntityPermission, BackendActionPermissionDAL>(permission);