добавлена смена статуса у покупки
This commit is contained in:
parent
8cc02e4532
commit
f032fc0f44
@ -76,7 +76,7 @@ namespace HardwareShopRestApi.Controllers
|
||||
{
|
||||
try
|
||||
{
|
||||
_purchaseLogic.Update(model);
|
||||
_purchaseLogic.DeliveryPurchase(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -324,6 +324,28 @@ namespace HardwareShopWorkerApp.Controllers
|
||||
APIClient.PostRequest("api/purchase/createpurchase", purchaseModel);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void UpdatePurchase(int id, int status)
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
if (id <= 0)
|
||||
{
|
||||
throw new Exception("Некорректный идентификатор");
|
||||
}
|
||||
if (status <= 0)
|
||||
{
|
||||
throw new Exception("Некорректный статус");
|
||||
}
|
||||
APIClient.PostRequest("api/purchase/updatepurchase", new PurchaseBindingModel
|
||||
{
|
||||
Id = id,
|
||||
PurchaseStatus = (PurchaseStatus)status
|
||||
});
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult WorkerReport()
|
||||
{
|
||||
|
@ -18,13 +18,11 @@
|
||||
<p>
|
||||
<a asp-controller="Home" asp-action="CreatePurchase" class="btn btn-primary mx-2">Добавить</a>
|
||||
<button type="button" class="btn btn-primary mx-2" id="delete">Удалить заказ</button>
|
||||
<button type="button" class="btn btn-primary mx-2" id="inwork">Выполняется</button>
|
||||
<button type="button" class="btn btn-primary mx-2" id="ready">Готов</button>
|
||||
<button type="button" class="btn btn-primary mx-2" id="done">Выдан</button>
|
||||
</p>
|
||||
</div>
|
||||
<div class="text-center" name="id">
|
||||
<table class="table">
|
||||
<div class="text-center">
|
||||
<table class="table" id="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
@ -100,10 +98,8 @@
|
||||
|
||||
var table = document.getElementById("table");
|
||||
var remove = document.getElementById("delete");
|
||||
var inwork = document.getElementById("inwork");
|
||||
var ready = document.getElementById("ready");
|
||||
var done = document.getElementById("done");
|
||||
var order = 0;
|
||||
var purchase = 0;
|
||||
for (var i = 1; i < table.rows.length; i++) {
|
||||
table.rows[i].onclick = function () {
|
||||
// remove the background from the previous selected row
|
||||
@ -114,46 +110,26 @@
|
||||
index = this.rowIndex;
|
||||
// add class selected to the row
|
||||
this.classList.toggle("selected");
|
||||
order = parseInt(this.cells[0].innerText);
|
||||
purchase = parseInt(this.cells[0].innerText);
|
||||
remove.addEventListener("click", () => {
|
||||
console.log('try to delete order')
|
||||
console.log('try to delete purchase')
|
||||
$.ajax(
|
||||
{
|
||||
url: `/Storekeeper/DeleteOrder`,
|
||||
url: `/Home/DeletePurchase`,
|
||||
type: 'POST',
|
||||
data: { id: order }
|
||||
data: { id: purchase }
|
||||
}
|
||||
)
|
||||
})
|
||||
inwork.addEventListener("click", () => {
|
||||
console.log('try to delete order')
|
||||
$.ajax(
|
||||
{
|
||||
url: `/Storekeeper/UpdateOrder`,
|
||||
type: 'POST',
|
||||
data: { id: order, status: 1 }
|
||||
}
|
||||
)
|
||||
})
|
||||
ready.addEventListener("click", () => {
|
||||
console.log('try to delete order')
|
||||
$.ajax(
|
||||
{
|
||||
url: `/Storekeeper/UpdateOrder`,
|
||||
type: 'POST',
|
||||
data: { id: order, status: 2 }
|
||||
}
|
||||
)
|
||||
).done(() => window.location.href = '/Home/Purchase')
|
||||
})
|
||||
done.addEventListener("click", () => {
|
||||
console.log('try to delete order')
|
||||
console.log('try to delete purchase')
|
||||
$.ajax(
|
||||
{
|
||||
url: `/Storekeeper/UpdateOrder`,
|
||||
url: `/Home/UpdatePurchase`,
|
||||
type: 'POST',
|
||||
data: { id: order, status: 3 }
|
||||
data: { id: purchase, status: 1 }
|
||||
}
|
||||
)
|
||||
).done(() => window.location.href = '/Home/Purchases')
|
||||
})
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user