Edit order fix
This commit is contained in:
parent
aa1e2bf2e4
commit
4137695876
@ -11,8 +11,11 @@ namespace ElectronicsShopUserApp {
|
|||||||
|
|
||||||
public static ClientViewModel? Client { get; set; } = null;
|
public static ClientViewModel? Client { get; set; } = null;
|
||||||
|
|
||||||
|
public static string port { get; set; } = string.Empty;
|
||||||
|
|
||||||
public static void Connect(IConfiguration configuration) {
|
public static void Connect(IConfiguration configuration) {
|
||||||
_client.BaseAddress = new Uri(configuration["IPAddress"]);
|
_client.BaseAddress = new Uri(configuration["IPAddress"]);
|
||||||
|
port = _client.BaseAddress.Port.ToString();
|
||||||
_client.DefaultRequestHeaders.Accept.Clear();
|
_client.DefaultRequestHeaders.Accept.Clear();
|
||||||
_client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
_client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
||||||
}
|
}
|
||||||
|
@ -199,25 +199,23 @@ namespace ElectronicsShopUserApp.Controllers {
|
|||||||
?? throw new Exception("Îøèáêà ïîëó÷åíèÿ ìîäåëè");
|
?? throw new Exception("Îøèáêà ïîëó÷åíèÿ ìîäåëè");
|
||||||
APIClient.PostRequestStr($"api/main/deleteproductorder", view.ID, id);
|
APIClient.PostRequestStr($"api/main/deleteproductorder", view.ID, id);
|
||||||
|
|
||||||
return RedirectToAction("OrderView");
|
return Redirect($"https://localhost:7219/Home/EditOrder/{view.ID}");
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IActionResult AddProduct() {
|
public IActionResult AddProduct(int id) {
|
||||||
ViewBag.Products = APIClient.GetRequset<List<ProductViewModel>>($"api/main/getproducts");
|
ViewBag.Products = APIClient.GetRequset<List<ProductViewModel>>($"api/main/getproducts");
|
||||||
return View();
|
return View(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[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}")
|
var _product = APIClient.GetRequset<ProductViewModel>($"api/main/getproduct?_productid={product}")
|
||||||
?? throw new Exception("Îøèáêà ïîëó÷åíèÿ òîâàðà");
|
?? throw new Exception("Îøèáêà ïîëó÷åíèÿ òîâàðà");
|
||||||
var _order = APIClient.GetRequset<OrderViewModel>($"api/main/getorder?_clientid={APIClient.Client?.ID}")
|
APIClient.ListPostRequest($"api/main/addproduct", _product, count, id);
|
||||||
?? throw new Exception("Îøèáêà ïîëó÷åíèÿ çàêàçà");
|
// ÿ íå çíàþ êàê òóò åùå íîðìàëüíî ñäåëàòü
|
||||||
|
Response.Redirect($"https://localhost:7219/Home/EditOrder/{id}");
|
||||||
APIClient.ListPostRequest($"api/main/addproduct", _product, count, _order.ID);
|
}
|
||||||
Response.Redirect("OrderView");
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IActionResult Payment(int id) {
|
public IActionResult Payment(int id) {
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
@{
|
@{
|
||||||
ViewData["Title"] = "AddProduct";
|
ViewData["Title"] = "AddProduct";
|
||||||
}
|
}
|
||||||
|
@model int
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
<h2 class="display-4">Добавить товар</h2>
|
<h2 class="display-4">Добавить товар</h2>
|
||||||
</div>
|
</div>
|
||||||
<form method="post">
|
<form method="post">
|
||||||
|
<input type="hidden" name="id" id="id" readonly value="@Model" />
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-4">Продукты:</div>
|
<div class="col-4">Продукты:</div>
|
||||||
<div class="col-8">
|
<div class="col-8">
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<p>
|
<p>
|
||||||
<a asp-action="AddProduct">Добавить товар</a>
|
<a asp-action="AddProduct" asp-route-ID="@Model.Item1">Добавить товар</a>
|
||||||
</p>
|
</p>
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<thead>
|
<thead>
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<p>
|
<p>
|
||||||
<a asp-action="AddProduct">Добавить товар</a>
|
<a asp-action="AddProduct" asp-route-ID="@Model.Item1">Добавить товар</a>
|
||||||
</p>
|
</p>
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<thead>
|
<thead>
|
||||||
|
Loading…
Reference in New Issue
Block a user