示例#1
0
        public void Insert_Delete_Category()
        {
            TextContent news1 = new TextContent(repository.Name, newsSchema.Name, textFolder.FullName);

            news1["Title"] = "title1";
            news1["body"]  = "body1";
            provider.Add(news1);

            TextContent category1 = new TextContent(repository.Name, "category", "category");

            category1["Title"] = "category1";
            provider.Add(category1);

            var categories = new Category[] { new Category()
                                              {
                                                  ContentUUID = news1.UUID, CategoryFolder = category1.FolderName, CategoryUUID = category1.UUID
                                              } };

            provider.AddCategories(news1, categories);
            provider.DeleteCategories(news1, categories);
            provider.AddCategories(news1, categories);
            provider.ClearCategories(news1);

            provider.ClearCategories(news1);
        }
示例#2
0
 public virtual void AddCategories(TEntity entity, params TextContent[] categories)
 {
     TextContentProvider.AddCategories(entity, categories.Select(it => new Category()
     {
         CategoryFolder = it.FolderName,
         CategoryUUID   = it.UUID,
         ContentUUID    = entity.UUID
     }).ToArray());
 }
示例#3
0
        public virtual void AddCategories(Repository repository, TextContent textContent, params TextContent[] categories)
        {
            var relations = categories.Select(it => new Category()
            {
                ContentUUID    = textContent.UUID,
                CategoryFolder = it.FolderName,
                CategoryUUID   = it.UUID
            });

            TextContentProvider.AddCategories(textContent, relations.ToArray());
        }
 public void Test_AddCategories()
 {
     provider.Add(news1);
     provider.Add(category1);
     provider.AddCategories(news1, categories);
     provider.ClearCategories(news1);
     provider.AddCategories(news1, categories);
     provider.DeleteCategories(news1, categories);
     provider.Delete(news1);
     provider.Delete(category1);
 }
示例#5
0
        public void TestAddCategory()
        {
            dynamic category1 = new TextContent(repository.Name, categorySchema.Name, categoryFolder.Name)
            {
                UserKey = "category1"
            };

            category1.Title = "category1";

            textContentProvider.Add(category1);

            dynamic category2 = new TextContent(repository.Name, categorySchema.Name, categoryFolder.Name)
            {
                UserKey = "category2"
            };

            category2.Title = "category2";

            textContentProvider.Add(category2);

            dynamic news1 = new TextContent(repository.Name, newsSchema.Name, newsFolder.Name)
            {
                UserKey = "news1"
            };

            news1.title = "news1";
            textContentProvider.Add(news1);

            textContentProvider.AddCategories(news1, new Category()
            {
                ContentUUID = news1.uuid, CategoryFolder = categoryFolder.FullName, CategoryUUID = (string)(category1.UUID)
            },
                                              new Category()
            {
                ContentUUID = news1.uuid, CategoryFolder = categoryFolder.FullName, CategoryUUID = (string)(category2.UUID)
            });

            textContentProvider.DeleteCategories(news1, new Category()
            {
                ContentUUID = news1.uuid, CategoryFolder = categoryFolder.FullName, CategoryUUID = (string)(category2.UUID)
            });
        }
示例#6
0
        public void TestClearCategory()
        {
            var     contentProvider = new TextContentProvider();
            dynamic category1       = new TextContent(repository.Name, categorySchema.Name, categoryFolder.Name);

            category1.UserKey = "TestClearCategory-category1";
            category1.Title   = "TestClearCategory-category1";
            contentProvider.Add(category1);
            dynamic content1 = new TextContent(repository.Name, newsSchema.Name, newsFolder.Name);

            content1.UserKey = "TestClearCategory-news1";
            content1.Title   = "TestClearCategory-news1";
            contentProvider.Add(content1);
            contentProvider.AddCategories(content1, new Category()
            {
                ContentUUID = content1.uuid, CategoryFolder = categoryFolder.Name, CategoryUUID = category1.UUID
            });

            contentProvider.ClearCategories(content1);
        }
示例#7
0
        public QueryTests()
        {
            EmptyUserKeyGenerator.DefaultGenerator = new EmptyUserKeyGenerator();
            Providers.DefaultProviderFactory       = new MongoDB.ProviderFactory();

            repository = new Repository(Kooboo.UniqueIdGenerator.GetInstance().GetBase32UniqueId(10).ToString());
            Providers.DefaultProviderFactory.GetProvider <IRepositoryProvider>().Add(repository);
            categorySchema = new Schema(repository, "category")
            {
                IsDummy = false
            };
            categorySchema.AddColumn(new Column()
            {
                Name = "Title"
            });
            categoryFolder = new TextFolder(repository, "Category")
            {
                SchemaName = categorySchema.Name, IsDummy = false
            };
            Providers.DefaultProviderFactory.GetProvider <ITextFolderProvider>().Add(categoryFolder);

            newsSchema = new Schema(repository, "News")
            {
                IsDummy = false
            };
            newsSchema.AddColumn(new Column()
            {
                Name = "title", DataType = Data.DataType.String
            });
            newsSchema.AddColumn(new Column()
            {
                Name = "Body", DataType = Data.DataType.String
            });
            newsSchema.AddColumn(new Column()
            {
                Name = "Comments", DataType = Data.DataType.Int
            });
            Providers.DefaultProviderFactory.GetProvider <ISchemaProvider>().Add(newsSchema);

            newsFolder = new TextFolder(repository, "News")
            {
                SchemaName = newsSchema.Name, Categories = new List <CategoryFolder>()
                {
                    new CategoryFolder()
                    {
                        FolderName = categoryFolder.FullName, SingleChoice = false
                    }
                }, OrderSetting = new OrderSetting()
                {
                    FieldName = "Sequence", Direction = OrderDirection.Descending
                }
            };
            Providers.DefaultProviderFactory.GetProvider <ITextFolderProvider>().Add(newsFolder);

            commentSchema = new Schema(repository, "Comment")
            {
                IsDummy = false
            };
            commentSchema.AddColumn(new Column()
            {
                Name = "Title"
            });
            Providers.DefaultProviderFactory.GetProvider <ISchemaProvider>().Add(commentSchema);

            category1          = new TextContent(repository.Name, categorySchema.Name, categoryFolder.FullName);
            category1["title"] = "category1";
            provider.Add(category1);

            category2          = new TextContent(repository.Name, categorySchema.Name, categoryFolder.FullName);
            category2["title"] = "category2";
            provider.Add(category2);

            newsContent             = new TextContent(repository.Name, newsSchema.Name, newsFolder.FullName);
            newsContent["title"]    = "news1";
            newsContent["body"]     = "body";
            newsContent["comments"] = 1;
            provider.Add(newsContent);

            news2             = new TextContent(repository.Name, newsSchema.Name, newsFolder.FullName);
            news2["title"]    = "news2";
            news2["body"]     = "body";
            news2["comments"] = 0;
            provider.Add(news2);

            news3             = new TextContent(repository.Name, newsSchema.Name, newsFolder.FullName);
            news3["title"]    = "news2";
            news3["body"]     = "body";
            news3["comments"] = 5;
            provider.Add(news3);

            provider.AddCategories(newsContent, new Category()
            {
                ContentUUID = newsContent.UUID, CategoryUUID = category1.UUID, CategoryFolder = category1.FolderName
            });
            provider.AddCategories(newsContent, new Category()
            {
                ContentUUID = newsContent.UUID, CategoryUUID = category2.UUID, CategoryFolder = category2.FolderName
            });

            commenContent = new TextContent(repository.Name, commentSchema.Name, "");
            commenContent.ParentFolder = newsContent.FolderName;
            commenContent.ParentUUID   = newsContent.UUID;
            commenContent["title"]     = "comment1";
            provider.Add(commenContent);
        }
示例#8
0
        public void TestClearCategory()
        {
            var contentProvider = new TextContentProvider();
            dynamic category1 = new TextContent(repository.Name, categorySchema.Name, categoryFolder.Name);
            category1.UserKey = "TestClearCategory-category1";
            category1.Title = "TestClearCategory-category1";
            contentProvider.Add(category1);
            dynamic content1 = new TextContent(repository.Name, newsSchema.Name, newsFolder.Name);
            content1.UserKey = "TestClearCategory-news1";
            content1.Title = "TestClearCategory-news1";
            contentProvider.Add(content1);
            contentProvider.AddCategories(content1, new Category() { ContentUUID = content1.uuid, CategoryFolder = categoryFolder.Name, CategoryUUID = category1.UUID });

            contentProvider.ClearCategories(content1);
        }