organized files
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Customers</title>
|
||||
<link rel="stylesheet" type="text/css" href="style.css">
|
||||
<link rel="stylesheet" type="text/css" href="../style.css">
|
||||
<script src="customers.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Employees</title>
|
||||
<link rel="stylesheet" type="text/css" href="style.css">
|
||||
<link rel="stylesheet" type="text/css" href="../style.css">
|
||||
<script src="employees.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
@@ -7,12 +7,12 @@
|
||||
</head>
|
||||
<body>
|
||||
<h1>Tables</h1>
|
||||
<a href="services.html" class="button">Services</a>
|
||||
<a href="services/services.html" class="button">Services</a>
|
||||
<br>
|
||||
<a href="employees.html" class="button">Employees</a>
|
||||
<a href="employees/employees.html" class="button">Employees</a>
|
||||
<br>
|
||||
<a href="customers.html" class="button">Customers</a>
|
||||
<a href="customers/customers.html" class="button">Customers</a>
|
||||
<br>
|
||||
<a href="maintainerteam.html" class="button">Maintainer Team</a>
|
||||
<a href="maintainer_teams/maintainerteam.html" class="button">Maintainer Team</a>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Maintainer Team</title>
|
||||
<link rel="stylesheet" type="text/css" href="style.css">
|
||||
<link rel="stylesheet" type="text/css" href="../style.css">
|
||||
<script src="maintainerteam.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
@@ -1,93 +0,0 @@
|
||||
let customers = [];
|
||||
getCustomers();
|
||||
|
||||
async function getCustomers()
|
||||
{
|
||||
await fetch('https://localhost:5001/api/Customer')
|
||||
.then(x => x.json())
|
||||
.then(y => {
|
||||
customers = y;
|
||||
console.log(customers);
|
||||
display();
|
||||
});
|
||||
} customers.forEach(customer => {
|
||||
|
||||
|
||||
})
|
||||
|
||||
function display()
|
||||
{
|
||||
document.getElementById('resultarea').innerHTML = '';
|
||||
|
||||
customers.forEach(t => {
|
||||
document.getElementById('resultarea').innerHTML +=
|
||||
'<tr><td>'
|
||||
+ t.id +
|
||||
'</td><td>'
|
||||
+ t.name +
|
||||
'</td><td>'
|
||||
+ '<button type="button" onclick="deleteCustomer(' + t.id + ')">Delete</button>'
|
||||
+ '</td><td>'
|
||||
+ '<button type="button" onclick="updateCustomer(' + t.id + ')">Update</button>'
|
||||
+ '</td></tr>';
|
||||
});
|
||||
}
|
||||
|
||||
function updateCustomer(id)
|
||||
{
|
||||
let customerId = document.getElementById('customerid').value;
|
||||
let customerName = document.getElementById('customername').value;
|
||||
let customerPhone = document.getElementById('customerphone').value;
|
||||
let customerEmail = document.getElementById('customeremail').value;
|
||||
let customerServiceId = document.getElementById('customerserviceid').value;
|
||||
|
||||
|
||||
fetch ('https://localhost:5001/api/Customer/' + id, {
|
||||
method: 'PUT',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
name: 'Updated Name',
|
||||
phone: 'Updated Phone',
|
||||
customerEmail: 'Updated Email'
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function addCustomer()
|
||||
{
|
||||
let customerName = document.getElementById('customername').value;
|
||||
let customerPhone = document.getElementById('customerphone').value;
|
||||
let customerEmail = document.getElementById('customeremail').value;
|
||||
|
||||
fetch('https://localhost:5001/api/Customer', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
name: customerName,
|
||||
phone: customerPhone,
|
||||
customerEmail: customerEmail
|
||||
})
|
||||
})
|
||||
.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 =>
|
||||
{
|
||||
console.log("Success: ", data)
|
||||
getCustomers();
|
||||
})
|
||||
.catch(error => console.error("Error: ", error));
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>services</title>
|
||||
<link rel="stylesheet" type="text/css" href="style.css">
|
||||
<link rel="stylesheet" type="text/css" href="../style.css">
|
||||
<script src="services.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
Reference in New Issue
Block a user