groceries/Groceries/Common/_TablePaginator.cshtml
2023-07-23 20:00:53 +01:00

34 lines
1.0 KiB
Plaintext

@model IListPageModel
@{
var routeData = new Dictionary<string, string>(
ViewContext.RouteData.Values
.Where(data => data.Value != null)
.Select(data => KeyValuePair.Create(data.Key, (string)data.Value!))
.Concat(Context.Request.Query.Select(param => KeyValuePair.Create(param.Key, (string)param.Value!))));
}
<div class="table__paginator">
<span>
Showing @(Model!.Offset + 1) to @(Model.Offset + Model.Count) of @Model.Total results
</span>
<nav class="button-group">
@if (Model.Page == 1)
{
<span class="link link--disabled">Previous</span>
}
else
{
<a class="link" asp-all-route-data="routeData" asp-route-page="@(Model.Page - 1)">Previous</a>
}
@if (Model.Page == Model.LastPage)
{
<span class="link link--disabled">Next</span>
}
else
{
<a class="link" asp-all-route-data="routeData" asp-route-page="@(Model.Page + 1)">Next</a>
}
</nav>
</div>