пагинация веб (пункт 2)
This commit is contained in:
parent
fe0d9c7ecc
commit
cc8ed1c606
@ -144,13 +144,16 @@ namespace ShipyardClientApp.Controllers
|
||||
return count * (prod?.Price ?? 1);
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult Mails()
|
||||
public IActionResult Mails(int page=0)
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return View(APIClient.GetRequest<List<MessageInfoViewModel>>($"api/client/getmessages?clientId={APIClient.Client.Id}"));
|
||||
var messages = APIClient.GetRequest<List<MessageInfoViewModel>>($"api/client/getmessages?clientId={APIClient.Client.Id}&page={page}");
|
||||
ViewBag.IsLast = messages!.Count() == 0 ? true : false;
|
||||
ViewBag.Page = page;
|
||||
return View(messages);
|
||||
}
|
||||
}
|
||||
}
|
@ -50,4 +50,18 @@
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
@if (ViewBag.Page > 0)
|
||||
{
|
||||
<a href="@Url.Action("Mails", new { page = ViewBag.Page - 1 })"
|
||||
class="btn btn-default">
|
||||
« Предыдущая
|
||||
</a>
|
||||
}
|
||||
@if (!ViewBag.IsLast)
|
||||
{
|
||||
<a href="@Url.Action("Mails", new { page = ViewBag.Page + 1 })"
|
||||
class="btn btn-default">
|
||||
Следующая »
|
||||
</a>
|
||||
}
|
||||
</div>
|
@ -69,13 +69,15 @@ namespace ShipyardRestApi.Controllers
|
||||
}
|
||||
}
|
||||
[HttpGet]
|
||||
public List<MessageInfoViewModel>? GetMessages(int clientId)
|
||||
public List<MessageInfoViewModel>? GetMessages(int clientId,int page,int countPerPage = 5)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _mailLogic.ReadList(new MessageInfoSearchModel
|
||||
{
|
||||
ClientId = clientId
|
||||
ClientId = clientId,
|
||||
Page = page,
|
||||
PageCount = countPerPage
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
Loading…
x
Reference in New Issue
Block a user