mirror of
https://github.com/dotnet/skills.git
synced 2026-09-20 09:49:54 +08:00
e4670b33a1
* Add code testing agent agents + tests PoC * Remove AssertionEvaluator.cs change (moved to dev/jankrivanek/agents-evals)
34 lines
944 B
C#
34 lines
944 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace ContosoUniversity
|
|
{
|
|
public class PaginatedList<T> : List<T>
|
|
{
|
|
public int PageIndex { get; private set; }
|
|
public int TotalPages { get; private set; }
|
|
|
|
public PaginatedList(List<T> items, int count, int pageIndex, int pageSize)
|
|
{
|
|
PageIndex = pageIndex;
|
|
TotalPages = (int)Math.Ceiling(count / (double)pageSize);
|
|
|
|
this.AddRange(items);
|
|
}
|
|
|
|
public bool HasPreviousPage => PageIndex > 1;
|
|
|
|
public bool HasNextPage => PageIndex < TotalPages;
|
|
|
|
public static PaginatedList<T> Create(IQueryable<T> source, int pageIndex, int pageSize)
|
|
{
|
|
var count = source.Count();
|
|
var items = source.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList();
|
|
return new PaginatedList<T>(items, count, pageIndex, pageSize);
|
|
}
|
|
}
|
|
|
|
|
|
}
|