Ejemplo n.º 1
0
 public void Delete(string name)
 {
     if (Exists(name))
     {
         var dataType = _dataTypeService.GetDataTypeDefinitionByName(name);
         _dataTypeService.Delete(dataType);
     }
 }
Ejemplo n.º 2
0
        public void Deleting_DataType()
        {
            var dataType = CreateAndSaveDataType();

            dataTypeService.Delete(dataType);
            var lost = dataTypeService.GetDataTypeDefinitionById(dataType.Id);

            Assert.IsNull(lost);
        }
Ejemplo n.º 3
0
        public void Delete()
        {
            var dataTypeDefinition = DataTypeService.GetAllDataTypeDefinitions().FirstOrDefault(x => x.Name == DataTypeDefinition.Name);

            if (dataTypeDefinition == null)
            {
                throw new FluentException(string.Format("The Data Type Definition `{0}` does not exist.", DataTypeDefinition.Name));
            }

            UmbracoDatabase.Delete <DataTypePreValueDto>("WHERE datatypeNodeId = @NodeId", new { NodeId = DataTypeDefinition.Id });

            DataTypeService.Delete(dataTypeDefinition);
        }
Ejemplo n.º 4
0
        public IActionResult DeleteById(int id)
        {
            var foundType = _dataTypeService.GetDataType(id);

            if (foundType == null)
            {
                return(NotFound());
            }
            var currentUser = _backOfficeSecurityAccessor.BackOfficeSecurity.CurrentUser;

            _dataTypeService.Delete(foundType, currentUser.Id);

            return(Ok());
        }
        public void Convert(string name)
        {
            var archetypeDataType = _dataTypeService.GetDataTypeDefinitionByName(name);

            var nestedContentDataType = CreateNestedContentDataType(archetypeDataType);
            var archetypeContentTypes = ArchetypeContentTypes(archetypeDataType);

            foreach (var archetypeContentType in archetypeContentTypes)
            {
                ConvertInsideNestedContents(archetypeContentType.Alias, Alias(archetypeDataType.Name + "nc"));
                ConvertArchetypeValuesToNestedContent(archetypeContentType.Id, archetypeDataType.Id, Alias(archetypeDataType.Name + "nc"));
            }

            foreach (var archetypeContentType in archetypeContentTypes)
            {
                foreach (var composition in archetypeContentType.ContentTypeComposition)
                {
                    if (Archetypes(composition.PropertyTypes, archetypeDataType).Any())
                    {
                        var compositionContentType = _contentTypeService.GetContentType(composition.Id);

                        var propertyTypes = Archetypes(compositionContentType.PropertyTypes, archetypeDataType).ToArray();
                        foreach (var propType in propertyTypes)
                        {
                            propType.DataTypeDefinitionId = nestedContentDataType.Id;
                            propType.PropertyEditorAlias  = NestedContentAlias;
                        }
                        _contentTypeService.Save(compositionContentType);
                    }
                }
                if (Archetypes(archetypeContentType.PropertyTypes, archetypeDataType).Any())
                {
                    var propertyTypes = Archetypes(archetypeContentType.PropertyTypes, archetypeDataType).ToArray();

                    foreach (var propType in propertyTypes)
                    {
                        propType.DataTypeDefinitionId = nestedContentDataType.Id;
                        propType.PropertyEditorAlias  = NestedContentAlias;
                    }
                    _contentTypeService.Save(archetypeContentType);
                }
            }

            _dataTypeService.Delete(archetypeDataType);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Convert the Archetype data types to their Nested Content equivalent
        /// </summary>
        /// <param name="archetypeContentTypes"></param>
        /// <param name="archetypeDataType"></param>
        /// <param name="nestedContentDataType"></param>
        private void ConvertDataType(IEnumerable <IContentType> archetypeContentTypes, IDataTypeDefinition archetypeDataType,
                                     IDataTypeDefinition nestedContentDataType)
        {
            foreach (var archetypeContentType in archetypeContentTypes)
            {
                foreach (var composition in archetypeContentType.ContentTypeComposition)
                {
                    if (composition.PropertyTypes.Any(IsArchetypeWithId(archetypeDataType.Id)))
                    {
                        var compositionContentType = _contentTypeService.GetContentType(composition.Id);

                        var propertyTypes = compositionContentType.PropertyTypes.Where(IsArchetypeWithId(archetypeDataType.Id))
                                            .ToArray();
                        foreach (var propType in propertyTypes)
                        {
                            propType.DataTypeDefinitionId = nestedContentDataType.Id;
                            propType.PropertyEditorAlias  = NestedContentAlias;
                        }

                        _contentTypeService.Save(compositionContentType);
                    }
                }

                if (archetypeContentType.PropertyTypes.Any(IsArchetypeWithId(archetypeDataType.Id)))
                {
                    var propertyTypes = archetypeContentType.PropertyTypes.Where(IsArchetypeWithId(archetypeDataType.Id)).ToArray();

                    foreach (var propType in propertyTypes)
                    {
                        propType.DataTypeDefinitionId = nestedContentDataType.Id;
                        propType.PropertyEditorAlias  = NestedContentAlias;
                    }

                    _contentTypeService.Save(archetypeContentType);
                }
            }

            _dataTypeService.Delete(archetypeDataType);

            Func <PropertyType, bool> IsArchetypeWithId(int id)
            {
                return(type => type.DataTypeDefinitionId == id && type.PropertyEditorAlias == ArchetypeAlias);
            }
        }
Ejemplo n.º 7
0
        public override uSyncAction DeleteItem(Guid key, string keyString)
        {
            IDataTypeDefinition item = null;

            if (key != Guid.Empty)
            {
                item = _dataTypeService.GetDataTypeDefinitionById(key);
            }

            /* delete only by key
             * if (item == null && !string.IsNullOrEmpty(keyString))
             *  item = _dataTypeService.GetDataTypeDefinitionByName(keyString);
             */

            if (item != null)
            {
                LogHelper.Info <DataTypeHandler>("Deleting datatype: {0}", () => item.Name);
                _dataTypeService.Delete(item);
                return(uSyncAction.SetAction(true, keyString, typeof(IDataTypeDefinition), ChangeType.Delete, "Removed"));
            }

            return(uSyncAction.Fail(keyString, typeof(IDataTypeDefinition), ChangeType.Delete, "Not found"));
        }
Ejemplo n.º 8
0
 protected override void DeleteItem(IDataType item)
 => dataTypeService.Delete(item);
Ejemplo n.º 9
0
 public ActionResult Delete(DataTypeDto categoryViewModel)
 {
     //var categoryService = new CategoryService();
     _dataTypeService.Delete(c => c.Id.Equals(categoryViewModel.Id));
     return(RedirectToAction("List"));
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Delete the old data type
 /// </summary>
 /// <param name="oldDataTypeDefinition"></param>
 private void DeleteOldDataType(IDataTypeDefinition oldDataTypeDefinition)
 {
     _dataTypeService.Delete(oldDataTypeDefinition);
 }
Ejemplo n.º 11
0
 public override void DeleteItem(IDataType item)
 => dataTypeService.Delete(item);