Compare commits

..

No commits in common. "277588130bea9ff48985dda2740e50a01ef0028f" and "f7bad7a0bf7d792d1ea2b2969e958485a11d4f07" have entirely different histories.

3 changed files with 55 additions and 31 deletions

View File

@ -256,6 +256,29 @@ 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,14 +16,6 @@
<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">
@ -62,11 +54,14 @@
<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">
@ -74,24 +69,4 @@
</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

@ -0,0 +1,26 @@
@{
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>