51 lines
1.4 KiB
C#
51 lines
1.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Koogle.Application.DTOs
|
|
{
|
|
/// <summary>
|
|
/// Ergebnis einer paginierten Abfrage.
|
|
/// </summary>
|
|
/// <typeparam name="T">Typ der Ergebnisse.</typeparam>
|
|
public record PagedResultDto<T>
|
|
{
|
|
/// <summary>
|
|
/// Die Ergebnisse der aktuellen Seite.
|
|
/// </summary>
|
|
public IReadOnlyList<T> Items { get; init; } = [];
|
|
|
|
/// <summary>
|
|
/// Gesamtanzahl der Ergebnisse (über alle Seiten).
|
|
/// </summary>
|
|
public int TotalCount { get; init; }
|
|
|
|
/// <summary>
|
|
/// Aktuelle Seitennummer.
|
|
/// </summary>
|
|
public int Page { get; init; }
|
|
|
|
/// <summary>
|
|
/// Anzahl der Einträge pro Seite.
|
|
/// </summary>
|
|
public int PageSize { get; init; }
|
|
|
|
/// <summary>
|
|
/// Gesamtanzahl der Seiten.
|
|
/// </summary>
|
|
public int TotalPages => PageSize > 0 ? (int)Math.Ceiling((double)TotalCount / PageSize) : 0;
|
|
|
|
/// <summary>
|
|
/// Gibt an, ob es eine vorherige Seite gibt.
|
|
/// </summary>
|
|
public bool HasPreviousPage => Page > 1;
|
|
|
|
/// <summary>
|
|
/// Gibt an, ob es eine nächste Seite gibt.
|
|
/// </summary>
|
|
public bool HasNextPage => Page < TotalPages;
|
|
}
|
|
}
|