コード例 #1
0
        public async Task FindCollectiondById()
        {
            var pageCollection = (await pageCollectionService.CreateCollectionAsync("Test collection", "TestPage", PageSortMode.FirstOld, null)).Data;

            var findedPageCollection = await pageCollectionService.FindCollectiondByIdAsync(pageCollection.Id);

            Assert.NotNull(findedPageCollection);
            Assert.Equal(pageCollection.Id, findedPageCollection.Id);
        }
コード例 #2
0
        public async Task <IActionResult> GetAsync([FromRoute] Guid id)
        {
            var pageCollection = await pageCollectionService.FindCollectiondByIdAsync(id);

            if (pageCollection == null)
            {
                return(NotFound());
            }

            var model = await GetItemModelAsync(pageCollection);

            return(Ok(model));
        }
コード例 #3
0
        public async Task <IActionResult> ListAsync([FromQuery] Guid collectionId)
        {
            var collection = await pageCollectionService.FindCollectiondByIdAsync(collectionId);

            if (collection == null)
            {
                return(BadRequest());
            }

            var result = new List <Models.PageModel>();

            var pages = await pageService.GetPagesAsync(new GetPagesOptions(collection.Id) { IncludeDrafts = true });

            foreach (var page in pages)
            {
                result.Add(await GetItemModelAsync(page));
            }

            return(Ok(result));
        }
コード例 #4
0
        protected override async Task OnInitializeAsync()
        {
            if (!RouteData.Values.TryGetValue("id", out object pageCollectionIdValue))
            {
                AddErrors("Not valid id.");
                return;
            }

            if (!Guid.TryParse(pageCollectionIdValue.ToString(), out Guid pageCollectionId))
            {
                AddErrors("Not valid id.");
                return;
            }

            pageCollection = await pageCollectionService.FindCollectiondByIdAsync(pageCollectionId);

            if (pageCollection == null)
            {
                AddErrors("Not found page collection.");
                return;
            }
        }
コード例 #5
0
        protected override async Task OnInitializeAsync()
        {
            if (!Request.Query.TryGetValue("collectionId", out string pageCollectionIdValue))
            {
                AddErrors("Not valid id.");
                return;
            }

            if (!Guid.TryParse(pageCollectionIdValue, out Guid pageCollectionId))
            {
                AddErrors("Not valid id.");
                return;
            }

            pageCollection = await pageCollectionService.FindCollectiondByIdAsync(pageCollectionId);

            if (pageCollection == null)
            {
                AddErrors("Not found page collection.");
                return;
            }
        }
コード例 #6
0
 protected override Task <IPageCollection> OnGetItemAsync(Guid id)
 {
     return(pageCollectionService.FindCollectiondByIdAsync(id));
 }