Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/Cortside.AspNetCore.Common/Models/PagedResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ public PagedResult(int totalItems, int pageNumber, int pageSize, IList<T> result
/// <summary>
/// Total number of paged result pages for given resource
/// </summary>
public int TotalPages => (int)Math.Ceiling(TotalItems / (double)PageSize);
public int TotalPages =>
PageSize <= 0
? 0
// Integer division with ceiling rounding
// See https://stackoverflow.com/a/4175152/539997
: (TotalItems + PageSize - 1) / PageSize;

/// <summary>
/// Current paged result page of results
Expand Down