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);
        }
        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));
        }
        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;
            }
        }
 protected override Task <IPageCollection> OnGetItemAsync(Guid id)
 {
     return(pageCollectionService.FindCollectiondByIdAsync(id));
 }