Небольшие исправления.

This commit is contained in:
Anastasia 2023-04-28 10:29:42 +04:00
parent bf4ec1f030
commit cbb0d15acd
3 changed files with 10 additions and 9 deletions

View File

@ -142,9 +142,9 @@ namespace JewelryStoreClientApp.Controllers
[HttpPost] [HttpPost]
public double Calc(int count, int jewel) 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);
} }
} }
} }

View File

@ -8,12 +8,12 @@
<div class="row"> <div class="row">
<div class="col-4">Изделие:</div> <div class="col-4">Изделие:</div>
<div class="col-8"> <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> </div>
<div class="row"> <div class="row">
<div class="col-4">Количество:</div> <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>
<div class="row"> <div class="row">
<div class="col-4">Сумма:</div> <div class="col-4">Сумма:</div>
@ -25,7 +25,7 @@
</div> </div>
</form> </form>
<script> <script>
$('#product').on('change', function () { $('#jewel').on('change', function () {
check(); check();
}); });
$('#count').on('change', function () { $('#count').on('change', function () {
@ -33,12 +33,12 @@ $('#count').on('change', function () {
}); });
function check() { function check() {
var count = $('#count').val(); var count = $('#count').val();
var product = $('#product').val(); var jewel = $('#jewel').val();
if (count && product) { if (count && jewel) {
$.ajax({ $.ajax({
method: "POST", method: "POST",
url: "/Home/Calc", url: "/Home/Calc",
data: { count: count, product: product }, data: { count: count, jewel: jewel },
success: function (result) { success: function (result) {
$("#sum").val(result); $("#sum").val(result);
} }

View File

@ -1,4 +1,5 @@
@model ClientViewModel @using JewelryStoreContracts.ViewModels
@model ClientViewModel
@{ @{
ViewData["Title"] = "Privacy Policy"; ViewData["Title"] = "Privacy Policy";
} }