public async Task CreateCollection_Fail_PageNotPublished()
        {
            var parentPageCollection = (await pageCollectionService.ListCollectionsAsync(null)).First();
            var page = await pageService.CreatePageAsync(parentPageCollection);

            var pageCollection = await pageCollectionService.CreateCollectionAsync("Test collection", "TestPage", PageSortMode.FirstOld, page.Id);

            Assert.False(pageCollection.Succeeded);
        }
        protected override async Task OnBuildListAsync(PageListModel listModel)
        {
            listModel.Parents     = new List <PagePathModel>();
            listModel.Collections = new List <PageCollectionModel>();

            if (page != null)
            {
                listModel.Parents.Add(await GetPathModelAsync(page));

                IPage currentPage = page;
                while (currentPage != null)
                {
                    var parentPageId = await pageService.GetParentPageIdAsync(currentPage);

                    if (!parentPageId.HasValue)
                    {
                        break;
                    }

                    currentPage = await pageService.FindPageByIdAsync(parentPageId.Value);

                    listModel.Parents.Add(await GetPathModelAsync(currentPage));
                }

                listModel.Parents.Reverse();
            }

            var collections = await pageCollectionService.ListCollectionsAsync(page?.Id);

            foreach (var collection in collections)
            {
                listModel.Collections.Add(await GetPageCollectionModelAsync(collection));
            }
        }
        public async Task <IActionResult> ListAsync([FromQuery] Guid?pageId)
        {
            var result = new List <Models.PageCollectionModel>();

            var collections = await pageCollectionService.ListCollectionsAsync(pageId);

            foreach (var pageCollection in collections)
            {
                result.Add(await GetItemModelAsync(pageCollection));
            }

            return(Ok(result));
        }
示例#4
0
        public async Task CreatePage_WithContentModel()
        {
            var pageCollection = (await pageCollectionService.ListCollectionsAsync(null)).First();

            var page = await pageService.CreatePageAsync(pageCollection, new TestPageContent { Title = "title" });

            Assert.NotNull(page);
            Assert.Equal(pageCollection.Id, page.OwnCollectionId);
            Assert.Equal(pageCollection.PageTypeName, page.TypeName);
            Assert.Equal("title", page.Header);
            Assert.NotNull(page.UrlPath);
        }
 protected override Task <IEnumerable <IPageCollection> > OnGetItemsAsync(int offset, int limit)
 {
     return(pageCollectionService.ListCollectionsAsync(page?.Id));
 }