Example #1
0
 public async Task <IActionResult> PageAsync([NotNull, FromQuery] CryspyPageContext context) =>
 Ok(await ApplicationService.PageAsync(context));
Example #2
0
        public async Task <CrispyPageResponse <CrispyApplicationPageResponse> > PageAsync([NotNull] CryspyPageContext context)
        {
            var response = new CrispyPageResponse <CrispyApplicationPageResponse>()
            {
                PageIndex = context.PageIndex, PageSize = context.PageSize
            };

            var total = await Query().CountAsync();

            response.Total = total;

            if (total == 0)
            {
                return(response);
            }

            response.Data = await Query().Page(context)
                            .OrderBy(x => x.DateTimeCreated)
                            .Select(x => new CrispyApplicationPageResponse(x.Id, x.Name))
                            .ToListAsync() ?? new List <CrispyApplicationPageResponse>();

            return(response);
        }
Example #3
0
 public static IQueryable <T> Page <T>(this IQueryable <T> query, CryspyPageContext context)
     where T : class, new() =>
 query.Skip(context.PageIndex * context.PageSize).Take(context.PageSize);