Beispiel #1
0
        public void Can_Perform_Delete_With_Heirarchy_On_ContentTypeRepository()
        {
            // Arrange
            IScopeProvider provider = ScopeProvider;

            using (IScope scope = provider.CreateScope())
            {
                ContentTypeRepository repository = ContentTypeRepository;
                ContentType           ctMain     = ContentTypeBuilder.CreateSimpleContentType(defaultTemplateId: 0);
                ContentType           ctChild1   = ContentTypeBuilder.CreateSimpleContentType("child1", "Child 1", ctMain, randomizeAliases: true, defaultTemplateId: 0);
                ContentType           ctChild2   = ContentTypeBuilder.CreateSimpleContentType("child2", "Child 2", ctChild1, randomizeAliases: true, defaultTemplateId: 0);

                repository.Save(ctMain);
                repository.Save(ctChild1);
                repository.Save(ctChild2);

                // Act
                IContentType resolvedParent = repository.Get(ctMain.Id);
                repository.Delete(resolvedParent);

                // Assert
                Assert.That(repository.Exists(ctMain.Id), Is.False);
                Assert.That(repository.Exists(ctChild1.Id), Is.False);
                Assert.That(repository.Exists(ctChild2.Id), Is.False);
            }
        }
        public ActionResult Delete(ContentType contentType)
        {
            contentTypeRepository.Delete(contentType);
            if (UnitOfWork.Save() != 1)
            {
                return(Content("{success:false}"));
            }

            return(Content("{success:true}"));
        }
        /// <summary>
        /// Executes before Disqus comments add-on is uninstalled to remove all related data.
        /// </summary>
        public override void BeforeUninstall()
        {
            var blockType = ContentTypeRepository.Load <CommentsBlock>();

            ContentModelUsage.ListContentOfContentType(blockType)
            .Select(usage => usage.ContentLink).Distinct().ToList()
            .ForEach(contentLink => ContentRepository.Delete(contentLink, true, AccessLevel.NoAccess));

            ContentTypeRepository.Delete(blockType);

            ConfigurationProvider.Clear();
        }
Beispiel #4
0
        public void Can_Perform_Delete_On_ContentTypeRepository()
        {
            // Arrange
            IScopeProvider provider = ScopeProvider;

            using (IScope scope = provider.CreateScope())
            {
                ContentTypeRepository repository = ContentTypeRepository;

                // Act
                ContentType contentType = ContentTypeBuilder.CreateSimpleContentType(defaultTemplateId: 0);
                repository.Save(contentType);

                IContentType contentType2 = repository.Get(contentType.Id);
                repository.Delete(contentType2);

                bool exists = repository.Exists(contentType.Id);

                // Assert
                Assert.That(exists, Is.False);
            }
        }