PIbd-23-Salin-O.A.-IceCream.../IceCreamShop/IceCreamShopsApp/Views/Home/Update.cshtml

79 lines
2.0 KiB
Plaintext
Raw Permalink Normal View History

2024-04-14 14:57:27 +04:00
@using IceCreamShopContracts.ViewModels;
@{
ViewData["Title"] = "Update";
}
<div class="text-center">
<h2 class="display-4">Редактирование магазина</h2>
</div>
<form method="post">
<div class="row">
<div class="col-4">Магазин:</div>
<div class="col-8">
<select id="shop" name="shop" class="form-control" asp-items="@(new SelectList(@ViewBag.Shops, "Id", "ShopName"))"></select>
</div>
</div>
<div class="row">
<div class="col-4">Название:</div>
<div class="col-8"><input type="text" name="name" id="name" class="form-control" /></div>
</div>
<div class="row">
<div class="col-4">Адрес:</div>
<div class="col-8"><input type="text" id="address" name="address" class="form-control" /></div>
</div>
<div class="row">
<div class="col-4">Дата открытия:</div>
<div class="col-8"><input type="datetime-local" id="dateopen" name="dateopen" class="form-control" required /></div>
</div>
<div class="row">
<div class="col-4">Вместимость:</div>
<div class="col-8"><input type="number" id="maxcapacity" name="maxcapacity" class="form-control" /></div>
</div>
<table class="table">
<thead>
<tr>
<th>
Мороженое
</th>
<th>
Количество
</th>
</tr>
</thead>
<tbody id="table-elements">
</tbody>
</table>
<div class="row">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Сохранить" class="btn btn-primary" /></div>
</div>
</form>
2024-04-14 16:46:26 +04:00
@section Scripts
{
<script>
function check() {
var shop = $('#shop').val();
if (shop) {
$.ajax({
method: "GET",
url: "/Home/GetShop",
data: { shopId: shop },
success: function (result) {
$('#name').val(result.item1.shopName);
$('#address').val(result.item1.address);
$('#dateopen').val(result.item1.dateOpen);
$('#maxcapacity').val(result.item1.maxCapacity);
$('#table-elements').html(result.item2);
}
});
};
}
2024-04-14 14:57:27 +04:00
check();
2024-04-14 16:46:26 +04:00
$('#shop').on('change', function () {
check();
});
</script>
}