diff --git a/HardwareShop/HardwareShopClientApp/Controllers/StorekeeperController.cs b/HardwareShop/HardwareShopClientApp/Controllers/StorekeeperController.cs index 81234e8..2010afc 100644 --- a/HardwareShop/HardwareShopClientApp/Controllers/StorekeeperController.cs +++ b/HardwareShop/HardwareShopClientApp/Controllers/StorekeeperController.cs @@ -322,7 +322,7 @@ namespace HardwareShopStorekeeperApp.Controllers { throw new Exception($"Цена комплектующего не может быть меньше или равна 0"); } - APIClient.PostRequest("api/component/updatedata", new ComponentBindingModel + APIClient.PostRequest("api/component/updatecomponent", new ComponentBindingModel { Id = component, ComponentName = name, diff --git a/HardwareShop/HardwareShopClientApp/Views/Storekeeper/CreateGood.cshtml b/HardwareShop/HardwareShopClientApp/Views/Storekeeper/CreateGood.cshtml index 778af83..100680f 100644 --- a/HardwareShop/HardwareShopClientApp/Views/Storekeeper/CreateGood.cshtml +++ b/HardwareShop/HardwareShopClientApp/Views/Storekeeper/CreateGood.cshtml @@ -25,6 +25,7 @@ Комплектующее + Стоимость Количество Сумма Действие @@ -74,28 +75,29 @@ console.log('try to add component') var count = $('#count').val(); var component = $('#component').val(); - if (component && count) - $.ajax({ - method: "GET", - url: `/Storekeeper/GetComponent`, - data: { Id: component }, - success: function (result) { - let flag = false - if (list.length > 0) { - list.forEach((elem) => { - if (elem.component.id === parseInt(result.id)) { - console.log('component already added') - flag = true - } - }) + if (component && count && count > 0) { + $.ajax({ + method: "GET", + url: `/Storekeeper/GetComponent`, + data: { Id: component }, + success: function (result) { + let flag = false + if (list.length > 0) { + list.forEach((elem) => { + if (elem.component.id === parseInt(result.id)) { + console.log('component already added') + flag = true + } + }) + } + if (!flag) list.push({ component: result, count: count }) + reloadTable() + countElem.value = '1' } - if (!flag) list.push({ component: result, count: count }) - reloadTable() - countElem.value = '1' - } - }).fail(function(xhr, textStatus, errorThrown) { - alert(xhr.responseText); - }) + }).fail(function(xhr, textStatus, errorThrown) { + alert(xhr.responseText); + }) + } }) saveBtn.addEventListener("click", () => { @@ -129,7 +131,7 @@ let price = 0; let count = 0; list.forEach((elem) => { - resultTable.innerHTML += `${elem.component.componentName}${elem.count}${Math.round(elem.component.cost * elem.count * 100) / 100} \ + resultTable.innerHTML += `${elem.component.componentName}${elem.component.cost}${elem.count}${Math.round(elem.component.cost * elem.count * 100) / 100} \
\