diff --git a/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/index.html b/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/index.html index 8591724..9fa1cbd 100644 --- a/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/index.html +++ b/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/index.html @@ -18,6 +18,7 @@ ID Name + Actions diff --git a/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/script.js b/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/script.js index e7d6a06..300c75a 100644 --- a/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/script.js +++ b/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/script.js @@ -10,7 +10,10 @@ async function getCustomers() console.log(customers); display(); }); -} +} customers.forEach(customer => { + + +}) function display() { @@ -22,6 +25,8 @@ function display() + t.id + '' + t.name + + '' + + '' + ''; }); } @@ -33,7 +38,24 @@ function addCustomer() fetch('https://localhost:5001/api/Customer', { method: 'POST', headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ name: customerName }) + body: JSON.stringify({ + name: customerName, + }) + }) + .then(response => response) + .then(data => + { + console.log("Success: ", data) + getCustomers(); + }) + .catch(error => console.error("Error: ", error)); +} + +function deleteCustomer(id) +{ + fetch('https://localhost:5001/api/Customer/' + id, { + method: 'DELETE', + headers: { 'Content-Type': 'application/json' }, }) .then(response => response) .then(data =>