94 lines
2.5 KiB
Plaintext
Raw Normal View History

2023-04-23 19:48:34 +04:00
@model List<SushiBarContracts.ViewModels.MessageInfoViewModel>
@{
ViewData["Title"] = "Mails";
}
<div class="text-center">
2023-05-05 01:49:24 +04:00
<h1 class="display-4">Mail</h1>
2023-04-23 19:48:34 +04:00
</div>
<div class="text-center">
@{
if (Model == null)
{
<h3 class="display-4">Авторизируйтесь</h3>
return;
}
<table class="table">
<thead>
<tr>
<th>
2023-05-05 01:49:24 +04:00
Date
2023-04-23 19:48:34 +04:00
</th>
<th>
2023-05-05 01:49:24 +04:00
Title
2023-04-23 19:48:34 +04:00
</th>
<th>
2023-05-05 01:49:24 +04:00
Text
2023-04-23 19:48:34 +04:00
</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem =>
item.DateDelivery)
</td>
<td>
@Html.DisplayFor(modelItem =>
item.Subject)
</td>
<td>
@Html.DisplayFor(modelItem =>
item.Body)
</td>
</tr>
}
</tbody>
</table>
}
2023-05-05 01:49:24 +04:00
<nav>
<ul class="pagination justify-content-center">
<li class="page-item">
<a class="page-link" href="#" id="prev">Previous</a>
</li>
<li class="page-item">
<a class="page-link" href="#" id="next">Next</a>
</li>
</ul>
</nav>
</div>
<script>
const url = document.location.href;
const urlPart1 = url.split('=')[0];
const urlParameter = url.split('=')[1];
let parameter = parseInt(urlParameter);
const go = () => {
window.location.href = window.location.protocol + "//" + window.location.host + `/Home/Mails?page=${parameter}`
}
const paginationNext = document.getElementById("next")
paginationNext.onclick = (e) => {
e.preventDefault();
if (isNaN(parameter)) {
parameter = 1
}
parameter++;
go();
}
const paginationPrev = document.getElementById("prev")
if (isNaN(parameter) || parameter === 1) {
paginationPrev.parentElement.classList.add("disabled");
}
paginationPrev.onclick = (e) => {
e.preventDefault();
parameter--;
if (parameter <= 0)
parameter = 1
go();
}
</script>