Небольшие исправления.
This commit is contained in:
parent
bf4ec1f030
commit
cbb0d15acd
@ -142,9 +142,9 @@ namespace JewelryStoreClientApp.Controllers
|
||||
[HttpPost]
|
||||
public double Calc(int count, int jewel)
|
||||
{
|
||||
var prod = APIClient.GetRequest<JewelViewModel>($"api/main/getjewel?jewelId={jewel}"
|
||||
var jew = APIClient.GetRequest<JewelViewModel>($"api/main/getjewel?jewelId={jewel}"
|
||||
);
|
||||
return count * (prod?.Price ?? 1);
|
||||
return count * (jew?.Price ?? 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,12 +8,12 @@
|
||||
<div class="row">
|
||||
<div class="col-4">Изделие:</div>
|
||||
<div class="col-8">
|
||||
<select id="product" name="product" class="form-control" aspitems="@(new SelectList(@ViewBag.Products,"Id", "ProductName"))"></select>
|
||||
<select id="jewel" name="jewel" class="form-control" asp-items="@(new SelectList(@ViewBag.Jewels,"Id", "JewelName"))"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Количество:</div>
|
||||
<div class="col-8"><input type="text" name="count" id="count""/></div>
|
||||
<div class="col-8"><input type="text" name="count" id="count"/></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Сумма:</div>
|
||||
@ -25,7 +25,7 @@
|
||||
</div>
|
||||
</form>
|
||||
<script>
|
||||
$('#product').on('change', function () {
|
||||
$('#jewel').on('change', function () {
|
||||
check();
|
||||
});
|
||||
$('#count').on('change', function () {
|
||||
@ -33,12 +33,12 @@ $('#count').on('change', function () {
|
||||
});
|
||||
function check() {
|
||||
var count = $('#count').val();
|
||||
var product = $('#product').val();
|
||||
if (count && product) {
|
||||
var jewel = $('#jewel').val();
|
||||
if (count && jewel) {
|
||||
$.ajax({
|
||||
method: "POST",
|
||||
url: "/Home/Calc",
|
||||
data: { count: count, product: product },
|
||||
data: { count: count, jewel: jewel },
|
||||
success: function (result) {
|
||||
$("#sum").val(result);
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
@model ClientViewModel
|
||||
@using JewelryStoreContracts.ViewModels
|
||||
@model ClientViewModel
|
||||
@{
|
||||
ViewData["Title"] = "Privacy Policy";
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user