2024-04-25 13:16:23 +04:00
|
|
|
@{
|
2024-05-01 10:50:16 +04:00
|
|
|
ViewData["Title"] = "Create";
|
2024-04-25 13:16:23 +04:00
|
|
|
}
|
|
|
|
<div class="text-center">
|
2024-05-01 10:50:16 +04:00
|
|
|
<h2 class="display-4">Создание заказа</h2>
|
2024-04-25 13:16:23 +04:00
|
|
|
</div>
|
|
|
|
<form method="post">
|
2024-05-01 10:50:16 +04:00
|
|
|
<div class="row">
|
|
|
|
<div class="col-4">Суши:</div>
|
|
|
|
<div class="col-8">
|
|
|
|
<select id="sushi" name="sushi" class="form-control">
|
|
|
|
@foreach (var sushi in ViewBag.Sushis)
|
|
|
|
{
|
|
|
|
<option value="@sushi.Id">@sushi.SushiName</option>
|
|
|
|
}
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-4">Количество:</div>
|
|
|
|
<div class="col-8">
|
|
|
|
<input type="text" name="count" id="count" />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-4">Сумма:</div>
|
|
|
|
<div class="col-8">
|
|
|
|
<input type="text" id="sum" name="sum" readonly />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-8"></div>
|
|
|
|
<div class="col-4">
|
|
|
|
<input type="submit" value="Создать" class="btn btn-primary" />
|
|
|
|
</div>
|
|
|
|
</div>
|
2024-04-25 13:16:23 +04:00
|
|
|
</form>
|
|
|
|
<script>
|
2024-05-01 10:50:16 +04:00
|
|
|
$('#sushi').on('change', function () {
|
|
|
|
check();
|
|
|
|
});
|
|
|
|
$('#count').on('change', function () {
|
|
|
|
check();
|
|
|
|
});
|
|
|
|
function check() {
|
|
|
|
var count = $('#count').val();
|
|
|
|
var sushi = $('#sushi').val();
|
|
|
|
if (count && sushi) {
|
|
|
|
$.ajax({
|
|
|
|
method: "POST",
|
|
|
|
url: "/Home/Calc",
|
|
|
|
data: { count: count, sushi: sushi },
|
|
|
|
success: function (result) {
|
|
|
|
var roundedResult = parseFloat(result).toFixed(2);
|
|
|
|
$("#sum").val(roundedResult);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
|
|
|
}
|
|
|
|
</script>
|