Edit order fix

This commit is contained in:
Илья Федотов 2024-07-26 16:01:31 +04:00
parent aa1e2bf2e4
commit 4137695876
5 changed files with 15 additions and 12 deletions

View File

@ -11,8 +11,11 @@ namespace ElectronicsShopUserApp {
public static ClientViewModel? Client { get; set; } = null;
public static string port { get; set; } = string.Empty;
public static void Connect(IConfiguration configuration) {
_client.BaseAddress = new Uri(configuration["IPAddress"]);
port = _client.BaseAddress.Port.ToString();
_client.DefaultRequestHeaders.Accept.Clear();
_client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
}

View File

@ -199,25 +199,23 @@ namespace ElectronicsShopUserApp.Controllers {
?? throw new Exception("Îøèáêà ïîëó÷åíèÿ ìîäåëè");
APIClient.PostRequestStr($"api/main/deleteproductorder", view.ID, id);
return RedirectToAction("OrderView");
return Redirect($"https://localhost:7219/Home/EditOrder/{view.ID}");
}
[HttpGet]
public IActionResult AddProduct() {
public IActionResult AddProduct(int id) {
ViewBag.Products = APIClient.GetRequset<List<ProductViewModel>>($"api/main/getproducts");
return View();
return View(id);
}
[HttpPost]
public void AddProduct(int product, int count) {
public void AddProduct(int product, int count, int id) {
var _product = APIClient.GetRequset<ProductViewModel>($"api/main/getproduct?_productid={product}")
?? throw new Exception("Îøèáêà ïîëó÷åíèÿ òîâàðà");
var _order = APIClient.GetRequset<OrderViewModel>($"api/main/getorder?_clientid={APIClient.Client?.ID}")
?? throw new Exception("Îøèáêà ïîëó÷åíèÿ çàêàçà");
APIClient.ListPostRequest($"api/main/addproduct", _product, count, _order.ID);
Response.Redirect("OrderView");
}
APIClient.ListPostRequest($"api/main/addproduct", _product, count, id);
// ÿ íå çíàþ êàê òóò åùå íîðìàëüíî ñäåëàòü
Response.Redirect($"https://localhost:7219/Home/EditOrder/{id}");
}
[HttpGet]
public IActionResult Payment(int id) {

View File

@ -1,10 +1,12 @@
@{
ViewData["Title"] = "AddProduct";
}
@model int
<div class="text-center">
<h2 class="display-4">Добавить товар</h2>
</div>
<form method="post">
<input type="hidden" name="id" id="id" readonly value="@Model" />
<div class="row">
<div class="col-4">Продукты:</div>
<div class="col-8">

View File

@ -28,7 +28,7 @@
</div>
</div>
<p>
<a asp-action="AddProduct">Добавить товар</a>
<a asp-action="AddProduct" asp-route-ID="@Model.Item1">Добавить товар</a>
</p>
<table class="table">
<thead>

View File

@ -28,7 +28,7 @@
</div>
</div>
<p>
<a asp-action="AddProduct">Добавить товар</a>
<a asp-action="AddProduct" asp-route-ID="@Model.Item1">Добавить товар</a>
</p>
<table class="table">
<thead>