Commit 242d1f32 authored by TTrueBenji's avatar TTrueBenji

Добавил панель навигации Bootstrap.

parent 6c248099
using System.Linq;
using System.Threading.Tasks;
using PhoneStore.Helpers;
using PhoneStore.Models;
......
......@@ -8,10 +8,12 @@ namespace PhoneStore.ViewModels
public int TotalPages { get; set; }
public bool HasPrevious => Page > 1;
public bool HasNext => Page < TotalPages;
public int Count { get; set; }
public PageViewModel(int page, int count, int pageSize)
{
Page = page;
Count = count;
TotalPages = (int)Math.Ceiling(count / (double)pageSize);
}
}
......
......@@ -55,23 +55,29 @@
</tr>
}
</table>
@if (Model.PageViewModel.HasPrevious)
{
<a
asp-action="Index"
asp-controller="Users"
asp-route-page="@(Model.PageViewModel.Page - 1)" class="btn btn-outline-warning"
asp-route-filterByName="@Model.Filter">
Назад
</a>
}
@if (Model.PageViewModel.HasNext)
{
<a
asp-action="Index"
asp-controller="Users"
asp-route-page="@(Model.PageViewModel.Page + 1)" class="btn btn-outline-warning"
asp-route-filterByName="@Model.Filter">
Вперед
</a>
}
\ No newline at end of file
<nav aria-label="Page navigation">
<ul class="pagination justify-content-left">
@if (Model.PageViewModel.HasPrevious)
{
<li class="page-item">
<a
asp-action="Index"
asp-controller="Users"
class="page-link"
asp-route-page="@(Model.PageViewModel.Page - 1)"
asp-route-filterByName="@Model.Filter">Previous</a>
</li>
}
@if (Model.PageViewModel.HasNext)
{
<li class="page-item">
<a
class="page-link"
asp-action="Index"
asp-controller="Users"
asp-route-page="@(Model.PageViewModel.Page + 1)"
asp-route-filterByName="@Model.Filter">Next</a>
</li>
}
</ul>
</nav>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment