Commit 242d1f32 authored by TTrueBenji's avatar TTrueBenji

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

parent 6c248099
using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using PhoneStore.Helpers; using PhoneStore.Helpers;
using PhoneStore.Models; using PhoneStore.Models;
......
...@@ -8,10 +8,12 @@ namespace PhoneStore.ViewModels ...@@ -8,10 +8,12 @@ namespace PhoneStore.ViewModels
public int TotalPages { get; set; } public int TotalPages { get; set; }
public bool HasPrevious => Page > 1; public bool HasPrevious => Page > 1;
public bool HasNext => Page < TotalPages; public bool HasNext => Page < TotalPages;
public int Count { get; set; }
public PageViewModel(int page, int count, int pageSize) public PageViewModel(int page, int count, int pageSize)
{ {
Page = page; Page = page;
Count = count;
TotalPages = (int)Math.Ceiling(count / (double)pageSize); TotalPages = (int)Math.Ceiling(count / (double)pageSize);
} }
} }
......
...@@ -55,23 +55,29 @@ ...@@ -55,23 +55,29 @@
</tr> </tr>
} }
</table> </table>
@if (Model.PageViewModel.HasPrevious) <nav aria-label="Page navigation">
{ <ul class="pagination justify-content-left">
@if (Model.PageViewModel.HasPrevious)
{
<li class="page-item">
<a <a
asp-action="Index" asp-action="Index"
asp-controller="Users" asp-controller="Users"
asp-route-page="@(Model.PageViewModel.Page - 1)" class="btn btn-outline-warning" class="page-link"
asp-route-filterByName="@Model.Filter"> asp-route-page="@(Model.PageViewModel.Page - 1)"
Назад asp-route-filterByName="@Model.Filter">Previous</a>
</a> </li>
} }
@if (Model.PageViewModel.HasNext) @if (Model.PageViewModel.HasNext)
{ {
<li class="page-item">
<a <a
class="page-link"
asp-action="Index" asp-action="Index"
asp-controller="Users" asp-controller="Users"
asp-route-page="@(Model.PageViewModel.Page + 1)" class="btn btn-outline-warning" asp-route-page="@(Model.PageViewModel.Page + 1)"
asp-route-filterByName="@Model.Filter"> asp-route-filterByName="@Model.Filter">Next</a>
Вперед </li>
</a> }
} </ul>
\ No newline at end of file </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