Add project
All checks were successful
SanStudent Multi-Project Deployment / deploy-api (push) Successful in 41s
SanStudent Multi-Project Deployment / deploy-frontadmin (push) Successful in 41s
SanStudent Multi-Project Deployment / deploy-frontstudent (push) Successful in 40s

This commit is contained in:
aherman-san
2026-03-07 11:14:26 +01:00
parent bca807d4c1
commit b8f03bf6d3
191 changed files with 122377 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
using Common.Dtos.Common;
using Microsoft.EntityFrameworkCore;
namespace Api.Extensions;
public static class PagingExtensions
{
public static async Task<PagedList<T>> ToPagedListAsync<T>(this IQueryable<T> queryable, int pageNumber, int pageSize)
{
var query = queryable;
int totalItemsCount = await queryable.CountAsync();
int totalPagesCount = (totalItemsCount / pageSize) + 1;
var number = Math.Min(pageNumber, totalPagesCount);
int skip = (number - 1) * pageSize;
var items = await query.Skip(skip).Take(pageSize).ToArrayAsync();
return new PagedList<T>(items, pageNumber, pageSize, totalItemsCount, totalPagesCount);
}
}