protected IContentRepository GetRepository(string repositoryType)
        {
            if (repositoryType == "GitHub")
            {
                var repository = new GitHubContentRepositoryImpl(
                    token: Environment.GetEnvironmentVariable("GithubToken"),
                    productHeaderValue: "VirtoCommerce",
                    ownerName: "VirtoCommerce",
                    repositoryName: "test-repository",
                    mainPath: _githubMainPath);

                return(repository);
            }
            else if (repositoryType == "Database")
            {
                EnsureDatabaseInitialized(() => new DatabaseContentRepositoryImpl(DatabaseName));
                return(new DatabaseContentRepositoryImpl(DatabaseName, new EntityPrimaryKeyGeneratorInterceptor(), new AuditableInterceptor()));
            }
            else if (repositoryType == "FileSystem")
            {
                var repository = new FileSystemContentRepositoryImpl(TempPath);
                return(repository);
            }

            throw new NullReferenceException(String.Format("{0} is not supported", repositoryType));
        }
Ejemplo n.º 2
0
        private FileSystemContentRepositoryImpl GetRepository()
        {
            var fullPath = string.Format("{0}\\Pages\\", _path);

            var repository = new FileSystemContentRepositoryImpl(fullPath);

            return(repository);
        }
Ejemplo n.º 3
0
        public void CanContentAddItems()
        {
            var fullPath = string.Format("{0}\\Themes\\", Environment.CurrentDirectory.Replace("\\bin\\Debug", string.Empty));

            var fileSystemFileRepository = new FileSystemContentRepositoryImpl(fullPath);
            var item = fileSystemFileRepository.GetContentItem("Apple/Simple/layout/theme.liquid").Result;

            var repository = _fixture.Db;

            var file1 = new ContentItem
            {
                Id          = Guid.NewGuid().ToString(),
                Path        = "Apple/Simple/layout/theme.liquid",
                Name        = "theme.liquid",
                CreatedDate = DateTime.UtcNow,
                ByteContent = item.ByteContent
            };

            repository.Add(file1);

            var file2 = new ContentItem
            {
                Id          = Guid.NewGuid().ToString(),
                Path        = "Apple/Simple/templates/404.liquid",
                Name        = "404.liquid",
                CreatedDate = DateTime.UtcNow,
                ByteContent = item.ByteContent
            };

            repository.Add(file2);

            var file3 = new ContentItem
            {
                Id          = Guid.NewGuid().ToString(),
                Path        = "Apple/Timber/templates/404.liquid",
                Name        = "404.liquid",
                CreatedDate = DateTime.UtcNow,
                ByteContent = item.ByteContent
            };

            repository.Add(file3);
            repository.UnitOfWork.Commit();
        }