コード例 #1
0
        public async Task <IActionResult> Index(CancellationToken cancellationToken, string username = null, Guid?folderId = null, int offset = 0, int?limit = null)
        {
            var token = await GetAccessTokenAsync();

            if (token == null)
            {
                return(Forbid());
            }

            var offset_param = PagingOffset.NewPagingOffset(offset);
            var limit_param  = limit is int l
                ? PagingLimit.NewPagingLimit(l)
                : PagingLimit.MaximumPagingLimit;

            var resp = await DeviantArtFs.Api.Gallery.AsyncPageGallery(
                token,
                ObjectExpansion.None,
                username != null
                ?UserScope.NewForUser(username)
                : UserScope.ForCurrentUser,
                folderId is Guid ff
                ?GalleryFolderScope.NewSingleGalleryFolder(ff)
                : GalleryFolderScope.AllGalleryFoldersPopular,
                limit_param,
                offset_param).StartAsTask(cancellationToken: cancellationToken);

            ViewBag.Username = username;
            ViewBag.FolderId = folderId;
            ViewBag.Limit    = limit;
            return(View(resp));
        }
コード例 #2
0
        public async Task <IActionResult> List(CancellationToken cancellationToken, string username = null)
        {
            var token = await GetAccessTokenAsync();

            if (token == null)
            {
                return(Forbid());
            }

            var list = await DeviantArtFs.Api.Gallery.AsyncGetFolders(
                token,
                CalculateSize.NewCalculateSize(true),
                FolderPreload.Default,
                username != null
                ?UserScope.NewForUser(username)
                : UserScope.ForCurrentUser,
                PagingLimit.MaximumPagingLimit,
                PagingOffset.StartingOffset).ToListAsync(cancellationToken);

            ViewBag.Username = username;
            return(View(list));
        }