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">
<a @if (Model.PageViewModel.HasPrevious)
asp-action="Index" {
asp-controller="Users" <li class="page-item">
asp-route-page="@(Model.PageViewModel.Page - 1)" class="btn btn-outline-warning" <a
asp-route-filterByName="@Model.Filter"> asp-action="Index"
Назад asp-controller="Users"
</a> class="page-link"
} asp-route-page="@(Model.PageViewModel.Page - 1)"
@if (Model.PageViewModel.HasNext) asp-route-filterByName="@Model.Filter">Previous</a>
{ </li>
<a }
asp-action="Index" @if (Model.PageViewModel.HasNext)
asp-controller="Users" {
asp-route-page="@(Model.PageViewModel.Page + 1)" class="btn btn-outline-warning" <li class="page-item">
asp-route-filterByName="@Model.Filter"> <a
Вперед class="page-link"
</a> asp-action="Index"
} asp-controller="Users"
\ No newline at end of file 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