From 10fb62b17e2d1c73fb51062dcbd427911334112b Mon Sep 17 00:00:00 2001 From: dasha Date: Fri, 19 May 2023 20:01:29 +0400 Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB?= =?UTF-8?q?=D0=B8=20=D0=B4=D0=B5=D1=81=D1=8F=D1=82=D1=8B=D0=B9=20=D0=B3?= =?UTF-8?q?=D1=80=D0=B0=D1=84=D0=B8=D0=BA.=20=D1=81=D0=B4=D0=B5=D0=BB?= =?UTF-8?q?=D0=B0=D0=BB=D0=B8=2012=20=D1=8D=D1=82=D0=B0=D0=BF=20=D0=BA?= =?UTF-8?q?=D1=83=D1=80=D1=81=D0=BE=D0=B2=D0=BE=D0=B9=20=D1=80=D0=B0=D0=B1?= =?UTF-8?q?=D0=BE=D1=82=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/StorekeeperController.cs | 2 +- .../Views/Storekeeper/CreateGood.cshtml | 46 ++++++++++--------- .../Views/Storekeeper/UpdateGood.cshtml | 44 +++++++++--------- .../Storekeeper/ComponentStorage.cs | 37 +++++++++++++-- .../Models/Storekeeper/Good.cs | 5 ++ .../Models/Worker/Build.cs | 5 ++ .../Controllers/ComponentController.cs | 15 ++++++ 7 files changed, 105 insertions(+), 49 deletions(-) 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} \
\