2023-04-09 19:05:54 +04:00
|
|
|
@{
|
|
|
|
ViewData["Title"] = "Cooks";
|
|
|
|
}
|
|
|
|
<body>
|
|
|
|
<div class="container">
|
|
|
|
<h2>Список поваров</h2>
|
2023-05-16 19:13:19 +04:00
|
|
|
<a type="button" class="btn btn-success" href="/Home/CreateCook">Добавить повара</a>
|
|
|
|
<button type="submit" class="btn btn-danger" form="selectCookForm">Удалить повара</button>
|
|
|
|
<a type="button" class="btn btn-warning" href="/Home/UpdateCook">Обновить повара</a>
|
2023-04-09 19:05:54 +04:00
|
|
|
<table class="table">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>Номер</th>
|
|
|
|
<th>ФИО</th>
|
|
|
|
<th>Должность</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
@foreach (var cook in ViewBag.Cooks)
|
|
|
|
{
|
2023-05-16 19:13:19 +04:00
|
|
|
<tr onclick="selectCook(this)">
|
|
|
|
<td>@cook.Id</td>
|
|
|
|
<td>@cook.FIO</td>
|
|
|
|
<td>@cook.Position</td>
|
|
|
|
</tr>
|
2023-04-09 19:05:54 +04:00
|
|
|
}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
2023-05-16 19:13:19 +04:00
|
|
|
</body>
|
|
|
|
<form id="selectCookForm" method="post" action="/Home/DeleteCook">
|
|
|
|
<input type="hidden" id="CookId" name="CookId" value="" />
|
|
|
|
</form>
|
|
|
|
<style>
|
|
|
|
.selected-row {
|
|
|
|
background-color: lightgray;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
<script>
|
|
|
|
function selectCook(row) {
|
|
|
|
var CookId = document.getElementById("CookId");
|
|
|
|
var previousValue = CookId.value;
|
|
|
|
var currentValue = row.cells[0].innerText;
|
|
|
|
|
|
|
|
if (previousValue === currentValue) {
|
|
|
|
CookId.value = "";
|
|
|
|
row.classList.remove("selected-row");
|
|
|
|
} else {
|
|
|
|
CookId.value = currentValue;
|
|
|
|
|
|
|
|
var rows = document.getElementsByTagName("tr");
|
|
|
|
for (var i = 0; i < rows.length; i++) {
|
|
|
|
rows[i].classList.remove("selected-row");
|
|
|
|
}
|
|
|
|
|
|
|
|
row.classList.add("selected-row");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|