work paymeant

This commit is contained in:
Игорь Гордеев 2024-06-01 03:18:46 +04:00
parent 216356dd73
commit 1674943bc6
5 changed files with 147 additions and 1 deletions

View File

@ -12,7 +12,7 @@ namespace ElectronicsShopDataBaseImplement
optionsBuilder) optionsBuilder)
{ {
if (optionsBuilder.IsConfigured == false) { if (optionsBuilder.IsConfigured == false) {
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-O0N00SH\SQLEXPRESS;Initial Catalog=ElectronicsShopDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-E2VPEN3\SQLEXPRESS;Initial Catalog=ElectronicsShopDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
} }
base.OnConfiguring(optionsBuilder); base.OnConfiguring(optionsBuilder);
} }

View File

@ -232,6 +232,53 @@ namespace ElectronicsShopUserApp.Controllers {
{ {
//ViewBag.Reports = APIClient.GetRequset<List<ProductViewModel>>($"api/main/getproducts"); Ïèñåì òàê æå ïîêà íåìà //ViewBag.Reports = APIClient.GetRequset<List<ProductViewModel>>($"api/main/getproducts"); Ïèñåì òàê æå ïîêà íåìà
return View(); return View();
}
public IActionResult Payment(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);
}
[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

@ -48,6 +48,7 @@
@Html.DisplayFor(modelItem => item.Sum) @Html.DisplayFor(modelItem => item.Sum)
</th> </th>
<td> <td>
<a class="btn btn-primary btn-sm" asp-action="Payment" asp-route-ID="@item.ID">Оплатить</a>
<a class="btn btn-primary btn-sm" asp-action="EditOrder" asp-route-ID="@item.ID">Изменить</a> <a class="btn btn-primary btn-sm" asp-action="EditOrder" asp-route-ID="@item.ID">Изменить</a>
<a class="btn btn-primary btn-sm" asp-action="DeleteOrder" asp-route-ID="@item.ID">Удалить</a> <a class="btn btn-primary btn-sm" asp-action="DeleteOrder" asp-route-ID="@item.ID">Удалить</a>
</td> </td>

View File

@ -0,0 +1,72 @@
@using ElectronicsShopContracts.ViewModels
@using ElectronicsShopDataModels.Models
@model (int, Dictionary<int, (IProductModel, int)>)
@{
ViewData["Title"] = "Payment";
}
<div class="text-center">
<h1 class="display-4">Оплата корзины</h1>
</div>
<form method="post">
<div class="row">
<div class="col-4"></div>
<div class="col-8">
<input id="id" type="hidden" name="id" readonly value="@Model.Item1" />
</div>
</div>
<div class=" text-center">
<table class="table">
<thead>
<tr>
<th>
Номер
</th>
<th>
Продукт
</th>
<th>
Количество
</th>
<th>
Сумма
</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model.Item2)
{
<tr class="element">
<th>
@Html.DisplayFor(modelItem => item.Key)
</th>
<th>
@Html.DisplayFor(modelItem => item.Value.Item1.ProductName)
</th>
<th class="count">
@Html.DisplayFor(modelItem => item.Value.Item2)
</th>
<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">
<input type="submit" value="Заказ готов, вернуться!" class="btn btn-primary" />
</div>
</div>
</div>
</form>

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>