Exemplo n.º 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));
        }
Exemplo n.º 2
0
        public IActionResult Index(int pageIndex = 1, int pageSize = 10)
        {
            var articles = articleQueries.FindArticles(PagingLimit.FromPageIndexAndSize(pageIndex, pageSize));

            HttpContext.Response.Headers.Add("title", DataTools.MakeWebTitle("首页", true));
            return(EnhancedView("Index", articles.Items));
        }
Exemplo n.º 3
0
        public Page <ArticleIndexData> FindArticles(PagingLimit paging)
        {
            IQueryable <Article> sql = context.Articles;

            if (paging != null)
            {
                sql = sql.Skip(paging.Offset).Take(paging.Limit);
            }

            var total = context.Articles.Count();
            var items = sql.Select(it => new ArticleIndexData {
                Id            = it.Id,
                Code          = it.Code,
                Title         = it.Title,
                SubTitle      = it.SubTitle,
                Summary       = it.Summary,
                Tags          = it.Tags ?? new List <Tag>(),
                CommentCounts = it.Comments.Count,
                CreateDate    = it.CreateDate,
                UpdateDate    = it.UpdateDate,
            }
                                   )
                        .ToList();

            return(new(items, total));
        }