public static PageMetadataProvider GetMetadata(this IPageMetadataManager pageMetadataManager, Type modelType)
        {
            var pageMetadataProvider = pageMetadataManager.FindPageMetadataByContentType(modelType);

            if (pageMetadataProvider == null)
            {
                throw new ArgumentException($"Тип страницы с типом {modelType.AssemblyQualifiedName} не найден.", nameof(pageMetadataProvider));
            }
            return(pageMetadataProvider);
        }
Beispiel #2
0
        public async Task CreatePage_WithDefaultHeader()
        {
            var pageCollection = (await pageCollectionService.ListCollectionsAsync(null)).First();
            var pageType       = pageMetadataManager.FindPageMetadataByContentType(typeof(TestPageContent));

            var page = await pageService.CreatePageAsync(pageCollection, pageType.Name);

            Assert.NotNull(page);
            Assert.Equal(pageCollection.Id, page.OwnCollectionId);
            Assert.Equal(pageCollection.PageTypeName, page.TypeName);
            Assert.Equal(TestPageContent.ContentTypeTitle, page.Header);
            Assert.NotNull(page.UrlPath);
        }
Beispiel #3
0
        public async Task <IActionResult> CreatePages()
        {
            var commonPageMetadata = pageMetadataManager.FindPageMetadataByContentType(typeof(Contents.Page.CommonPageContent));
            var newsPageMetadata   = pageMetadataManager.FindPageMetadataByContentType(typeof(Contents.Page.NewsPageContent));

            var mainPages = (await pageCollectionService.CreateCollectionAsync("Main pages", commonPageMetadata.Name, PageSortMode.FirstOld, null)).Data;

            var homePage = await pageService.CreatePageAsync(mainPages, new Contents.Page.CommonPageContent {
                Header = "Home page"
            });

            await pageService.PublishPageAsync(homePage, "index");

            var newsListPages = await pageService.CreatePageAsync(mainPages, new Contents.Page.NewsListPageContent {
                Header = "News"
            });

            await pageService.PublishPageAsync(newsListPages, "news");

            var newsPages = (await pageCollectionService.CreateCollectionAsync("Actual news", newsPageMetadata.Name, PageSortMode.FirstNew, newsListPages.Id)).Data;
            await pageCollectionService.CreateCollectionAsync("Archive news", newsPageMetadata.Name, PageSortMode.FirstNew, newsListPages.Id);

            var newsPage1 = await pageService.CreatePageAsync(newsPages, new Contents.Page.NewsPageContent {
                Header = "First news", SubHeader = "This is first news"
            });

            await pageService.PublishPageAsync(newsPage1, "first-news");

            var newsPage2 = await pageService.CreatePageAsync(newsPages, new Contents.Page.NewsPageContent {
                Header = "Second news", SubHeader = "This is second news"
            });

            await pageService.PublishPageAsync(newsPage2, "second-news");

            return(Ok("ok"));
        }
Beispiel #4
0
        async Task IAsyncLifetime.InitializeAsync()
        {
            var pageCollectionRepository = serviceScope.ServiceProvider.GetService <IPageCollectionRepository>();
            var pageRepository           = serviceScope.ServiceProvider.GetService <IPageRepository>();

            var pageType = pageMetadataManager.FindPageMetadataByContentType(typeof(TestPageContent));

            var pageCollection = await pageCollectionRepository.CreateCollectionAsync("test", "Test collection", pageType.Name, PageSortMode.FirstOld, null);

            var mainPage = await pageRepository.CreatePageAsync("test", pageCollection.Id, pageType.Name, "test", pageType.ContentMetadata.ConvertContentModelToDictionary(TestPageContent.CreateWithOnlyTitle("test")));

            await pageRepository.SetUrlPathAsync(mainPage, "index");

            await pageRepository.UpdatePageAsync(mainPage);

            var testPage = await pageRepository.CreatePageAsync("test", pageCollection.Id, pageType.Name, "test", pageType.ContentMetadata.ConvertContentModelToDictionary(TestPageContent.CreateWithOnlyTitle("test")));

            await pageRepository.SetUrlPathAsync(testPage, "test");

            await pageRepository.UpdatePageAsync(testPage);
        }