Skip to content

Commit 66fb686

Browse files
Merge pull request #292 from jeffreysSharp/develop
#273 - ViewComponent de paginação /sp8 - feature/sp8/#273
2 parents f366adf + b1f211e commit 66fb686

File tree

4 files changed

+39
-1
lines changed

4 files changed

+39
-1
lines changed

src/web/JSE.WebApp.MVC/Controllers/CatalogoController.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ public async Task<IActionResult> Index([FromQuery] int ps = 8, [FromQuery] int p
2222
{
2323
var produtos = await _catalogoService.ObterTodos(ps, page, q);
2424
ViewBag.Pesquisa = q;
25-
25+
produtos.ReferenceAction = "Index";
26+
2627
return View(produtos);
2728
}
2829

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using JSE.WebApp.MVC.Models;
2+
using Microsoft.AspNetCore.Mvc;
3+
4+
namespace JSE.WebApp.MVC.Extensions
5+
{
6+
public class PaginacaoViewComponent : ViewComponent
7+
{
8+
public IViewComponentResult Invoke(IPagedList modelopaginado)
9+
{
10+
return View(modelopaginado);
11+
}
12+
}
13+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
@model IPagedList
2+
3+
<nav aria-label="...">
4+
<ul class="pagination">
5+
@{
6+
for (var i = 1; i < Model.TotalPages + 1; i++)
7+
{
8+
if (i == Model.PageIndex)
9+
{
10+
<li class="page-item active">
11+
<a class="page-link" asp-action="@Model.ReferenceAction" asp-route-ps="@Model.PageSize" asp-route-page="@i" asp-route-q="@Model.Query">@i</a>
12+
</li>
13+
}
14+
else
15+
{
16+
<li class="page-item">
17+
<a class="page-link" asp-action="@Model.ReferenceAction" asp-route-ps="@Model.PageSize" asp-route-page="@i" asp-route-q="@Model.Query">@i</a>
18+
</li>
19+
}
20+
}
21+
}
22+
</ul>
23+
</nav>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+


0 commit comments

Comments
 (0)