Пример #1
0
        public async Task<IActionResult> Test()
        {
            var user = await _contentRepository
                .WithElevatedPermissions()
                .Users()
                .GetById(2)
                .AsMicroSummary()
                .ExecuteAsync();

            var image = await _contentRepository
                .ImageAssets()
                .GetById(2)
                .AsRenderDetails()
                .ExecuteAsync();

            var page = await _contentRepository
                .Pages()
                .Search()
                .AsRenderSummaries(new SearchPageRenderSummariesQuery()
                {
                    PageSize = 20,
                    PageDirectoryId = 2
                })
                .ExecuteAsync();

            var page2 = await _contentRepository
                .Pages()
                .GetById(1)
                .AsRenderSummary()
                .ExecuteAsync();

            // Perhaps NotFound should look like this:
            await _contentRepository
                .Pages()
                .NotFound()
                .GetByPath(new GetNotFoundPageRouteByPathQuery())
                .ExecuteAsync();

            var regions = await _contentRepository
                .Pages()
                .Versions()
                .Regions()
                .Blocks()
                .GetById(2)
                .AsRenderDetails(PublishStatusQuery.Latest)
                .ExecuteAsync();

            await _contentRepository
                .Pages()
                .GetByPath()
                .AsRoutingInfo(new GetPageRoutingInfoByPathQuery())
                .ExecuteAsync();
            //.PublishAsync(new PublishPageCommand() { PageId = 2 });

            var isUnique = await _contentRepository
                .Users()
                .IsUsernameUnique(new IsUsernameUniqueQuery()
                {
                    UserAreaCode = CofoundryAdminUserArea.AreaCode,
                    Username = "******"
                })
                .ExecuteAsync();

            int userId;

            using (var scope = _contentRepository
                .Transactions()
                .CreateScope()
            {
                var adminRole = await _contentRepository
                    .Roles()
                    .GetByCode(SuperAdminRole.SuperAdminRoleCode)
                    .AsDetails()
                    .ExecuteAsync();

                userId = await _contentRepository
                    .WithElevatedPermissions()
                    .Users()
                    .AddAsync(new AddUserCommand()
                    {
                        Email = Guid.NewGuid().ToString() + "@cofoundry.org",
                        Password = "******",
                        UserAreaCode = CofoundryAdminUserArea.AreaCode,
                        RoleId = adminRole.RoleId
                    });

                //await _contentRepository
                //    .WithElevatedPermissions()
                //    .ImageAssets()
                //    .DeleteAsync(2);

                await _contentRepository
                    .CustomEntities()
                    .Definitions()
                    .GetByCode(BlogPostCustomEntityDefinition.DefinitionCode)
                    .AsSummary()
                    .ExecuteAsync();

                await _contentRepository
                    .CustomEntities()
                    .DataModelSchemas()
                    .GetByCustomEntityDefinitionCode(BlogPostCustomEntityDefinition.DefinitionCode)
                    .AsDetails()
                    .ExecuteAsync();

                await _contentRepository
                    .CustomEntities()
                    .GetById(1)
                    .AsRenderSummary()
                    .ExecuteAsync();

                var permissions = await _contentRepository
                    .Roles()
                    .Permissions()
                    .GetAll()
                    .AsIPermission()
                    .ExecuteAsync();

                var directoryTree = await _contentRepository
                    .PageDirectories()
                    .GetAll()
                    .AsTree()
                    .ExecuteAsync();

                var rewriteRules = await _contentRepository
                    .RewriteRules()
                    .GetAll()
                    .AsSummaries()
                    .ExecuteAsync();

                var blockTypes = await _contentRepository
                    .PageBlockTypes()
                    .GetAll()
                    .AsSummaries()
                    .ExecuteAsync();

                await scope.CompleteAsync();
            }

            await _contentRepository
                .WithElevatedPermissions()
                .Users()
                .DeleteUserAsync(userId);

            return View();
        }