Compare commits

...

2 Commits

3 changed files with 31 additions and 55 deletions

View File

@ -256,29 +256,6 @@ namespace ElectronicsShopUserApp.Controllers {
(int, Dictionary<int, (IProductModel, int)>) tuple = (id, _productList);
return View(tuple);
}
[HttpGet]
public IActionResult PaymentProduct(int id)
{
if (APIClient.Client == null)
{
return Redirect("~/Home/Enter");
}
if (id == 0)
{
return Redirect("Orders");
}
var products = APIClient.GetRequset<List<List<string>>>($"api/main/getorderproducts?_orderid={id}");
foreach (var pr in products)
{
var product = JsonConvert.DeserializeObject<ProductViewModel>(pr[0]);
int count = JsonConvert.DeserializeObject<int>(pr[1]);
_productList.Add(product.ID, (product, count));
}
(int, Dictionary<int, (IProductModel, int)>) tuple = (id, _productList);
return View(tuple);
}
}
}

View File

@ -16,6 +16,14 @@
<div class="col-4"></div>
<div class="col-8">
<input id="id" type="hidden" name="id" readonly value="@Model.Item1" />
<div class="row">
<div class="col-4">Сумма платежа:</div>
<div class="col-8">
<input type="text" name="paysum" id="paysum" />
<input type="submit" value="Оплатить!" class="btn btn-primary" />
</div>
</div>
</div>
</div>
<div class=" text-center">
@ -54,14 +62,11 @@
<th class="countsum">
@Html.DisplayFor(modelItem => item.Value.Item1.Price)
</th>
<td>
<a class="btn btn-primary btn-sm" asp-action="PaymentProduct" asp-route-ID="@item.Key">Оплатить</a>
</td>
</tr>
}
</tbody>
</table>
<div class="row">
<div class="col-4"></div>
<div class="col-8">
@ -69,4 +74,24 @@
</div>
</div>
</div>
</form>
<script>
$('#paysum').on('change', function () {
check();
});
function check() {
var paysum = $('#paysum').val();
if (count && product) {
$.ajax({
method: "POST",
url: "/Home/Calc",
data: { paysum: paysum },
success: function (result) {
$("#sum").val(result);
}
});
};
}
</script>

View File

@ -1,26 +0,0 @@
@{
ViewData["Title"] = "AddProduct";
}
<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="product" name="product" class="form-control" asp-items="@(new SelectList(ViewBag.Products, "ID", "ProductName"))" readonly > </select>
</div>
</div>
<div class="row">
<div class="col-4">Сумма:</div>
<div class="col-8">
<input type="text" id="sum" name="sum" />
</div>
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4">
<input type="submit" value="Произвести оплату" class="btn btn-primary" />
</div>
</div>
</form>