Add pagination to the Jobs / Shifts / Talent list pages
CI/CD / CI · dotnet build (push) Successful in 2m50s
CI/CD / Deploy · hamkadr (push) Successful in 5m42s

The list pages loaded EVERY matching listing into one page (/Jobs was a ~2.6MB page with 1000+
cards) — no pagination at all. Add server-side paging (24/page, DB Skip/Take; near-me still sorts
all by distance then paginates in memory). The header count now shows the true total, and a shared
_Pager partial renders prev/next + a windowed page list that preserves all active filters in the URL.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
soroush.asadi
2026-06-23 19:27:41 +03:30
parent ccc5a954dd
commit 5fcdb8599f
8 changed files with 111 additions and 17 deletions
@@ -0,0 +1,51 @@
@model (int Current, int Total)
@{
var (cur, total) = Model;
}
@if (total > 1)
{
@* Build a page URL that preserves every current filter in the query string. *@
Func<int, string> pageUrl = p =>
{
var parts = Context.Request.Query
.Where(kv => !string.Equals(kv.Key, "Page", StringComparison.OrdinalIgnoreCase))
.Select(kv => Uri.EscapeDataString(kv.Key) + "=" + Uri.EscapeDataString(kv.Value.ToString()))
.ToList();
parts.Add("Page=" + p);
return Context.Request.Path + "?" + string.Join("&", parts);
};
var from = Math.Max(1, cur - 2);
var to = Math.Min(total, cur + 2);
<nav class="pager" aria-label="صفحه‌بندی">
@if (cur > 1)
{
<a class="pager-btn" href="@pageUrl(cur - 1)" rel="prev">→ قبلی</a>
}
@if (from > 1)
{
<a class="pager-num" href="@pageUrl(1)">@JalaliDate.ToPersianDigits("1")</a>
@if (from > 2) { <span class="pager-gap">…</span> }
}
@for (var p = from; p <= to; p++)
{
if (p == cur)
{
<span class="pager-num active" aria-current="page">@JalaliDate.ToPersianDigits(p.ToString())</span>
}
else
{
<a class="pager-num" href="@pageUrl(p)">@JalaliDate.ToPersianDigits(p.ToString())</a>
}
}
@if (to < total)
{
@if (to < total - 1) { <span class="pager-gap">…</span> }
<a class="pager-num" href="@pageUrl(total)">@JalaliDate.ToPersianDigits(total.ToString())</a>
}
@if (cur < total)
{
<a class="pager-btn" href="@pageUrl(cur + 1)" rel="next">بعدی ←</a>
}
</nav>
}