-
-
Save kshkong97/d94864cdb2a32cc24215916d6ead1c7b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@model IEnumerable<WebApplication4.Loan> | |
@{ | |
ViewBag.Title = "Index"; | |
} | |
@Html.ActionLink("Current Loans", "Index", "Borrowers")| | |
@Html.ActionLink("Customer Details", "Index", "Customers") | |
<h2>Loan submission page</h2> | |
<html> | |
<style> | |
h2{ | |
font-family:Corbel; | |
} | |
table, th, td { | |
border: 1px solid black; | |
background-color: snow; | |
border-collapse: collapse | |
} | |
body{ | |
font-family: 'Open Sans', sans-serif; | |
background-color:ghostwhite; | |
font-size:15px; | |
} | |
input{ | |
color:black; | |
background-color:ghostwhite; | |
margin: 15px; | |
} | |
div { | |
color: black; | |
} | |
#loanrequests { | |
background-color:#CAE4F7; | |
color:black; | |
padding: 10px; | |
margin: 10px; | |
} | |
#CustomerDetails { | |
color: black; | |
background-color:#CAE4F7; | |
padding: 10px; | |
margin: 10px; | |
} | |
#LoanForm { | |
color: white; | |
background-color:#2088CE; | |
width: 800; | |
padding: 10px; | |
margin: 20px; | |
} | |
.button { | |
background-color: #4CAF50; /* Green */ | |
border: none; | |
color: white; | |
padding: 10px 24px; | |
text-align: center; | |
text-decoration: none; | |
display: inline-block; | |
font-size: 12px; | |
margin: 4px 2px; | |
transition-duration: 0.4s; | |
cursor: pointer; | |
} | |
.button { | |
background-color: white; | |
color: black; | |
border: 2px solid #008CBA; | |
} | |
.button:hover { | |
background-color: #008CBA; | |
color: ghostwhite; | |
} | |
label { | |
width: 150px; | |
display: inline-block; | |
text-align: right; | |
} | |
</style> | |
<body> | |
<div> | |
<!-- Customer Details --> | |
<div id="CustomerDetails"> | |
<h3 id="LoanForm"> | |
Customer Details </h3> <br> | |
<label for="GetDetailsAddress"> Customer address:</label> | |
<input type="text" id="GetDetailsAddress" name="GetDetailsAddress" size="50" ><br><br> | |
<button class="button" id="GetCount"> Get Details </button> <br><br> | |
<h4 style="display: inline;">Array Count:</h4> | |
<h4 style="display: inline;" id='ArrayCount'> </h4> <br><br> <br> | |
<h4 style="display: inline;">Current credit:</h4> | |
<h4 style="display: inline;" id='CreditUsage'> </h4><br><br> <br> | |
<h4 style="display: inline;">Credit Limit:</h4> | |
<h4 style="display: inline;" id='CreditLimit'></h4> <br><br> <br> | |
<h4 style="display: inline;">Customer Name:</h4> | |
<h4 style="display: inline;" id='CustomerName'></h4> <br><br> <br> | |
<h3 id="LoanForm"> | |
Loan submission form</h3><br><br> | |
<b> | |
<label for="customeraddress"> | |
Customer Address:</label> | |
<input type="text" id="customeraddress" name="customeraddress" size="50"><br><br><br> | |
<label for="lname"> Loan name:</label> | |
<input type="text" id="lname" name="lname" size="50"><br><br><br> | |
<label for="ldate"> Loan Date:</label> | |
<input type="text" id="ldate" name="ldate" size="50"><br><br><br> | |
<label for="lamount"> Loan amount:</label> | |
<input type="text" id="lamount" name="lamount" size="50"><br><br><br> | |
<button class="button" id="SetArray"> Submit Loan </button> <br><br><br> | |
</b> | |
</div> | |
</div> | |
<link rel="stylesheet" type="text/css" href="style18.css"> | |
<title>Front-End Blockchain </title> | |
<script language="javascript" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> | |
<script src="https://cdn.jsdelivr.net/npm/web3@latest/dist/web3.min.js"></script> | |
<script> | |
var Contract; | |
ethereum.enable() | |
.then(function (accounts) { | |
}) | |
.catch(function (error) { | |
console.error(error) | |
}) | |
$(document).ready(function () { | |
web3js = new Web3(web3.currentProvider); | |
var address = "0x357Fd8A5375d48a25A94Da0A706c1c1888B18e75"; | |
var abi = [ | |
{ | |
"inputs": [], | |
"stateMutability": "nonpayable", | |
"type": "constructor" | |
}, | |
{ | |
"inputs": [ | |
{ | |
"internalType": "address", | |
"name": "_address", | |
"type": "address" | |
}, | |
{ | |
"internalType": "uint256", | |
"name": "_amount", | |
"type": "uint256" | |
} | |
], | |
"name": "CheckCredit", | |
"outputs": [ | |
{ | |
"internalType": "bool", | |
"name": "", | |
"type": "bool" | |
} | |
], | |
"stateMutability": "view", | |
"type": "function" | |
}, | |
{ | |
"inputs": [ | |
{ | |
"internalType": "address", | |
"name": "", | |
"type": "address" | |
} | |
], | |
"name": "CreditLimit", | |
"outputs": [ | |
{ | |
"internalType": "uint256", | |
"name": "", | |
"type": "uint256" | |
} | |
], | |
"stateMutability": "view", | |
"type": "function" | |
}, | |
{ | |
"inputs": [ | |
{ | |
"internalType": "address", | |
"name": "", | |
"type": "address" | |
} | |
], | |
"name": "CurrentCredit", | |
"outputs": [ | |
{ | |
"internalType": "uint256", | |
"name": "", | |
"type": "uint256" | |
} | |
], | |
"stateMutability": "view", | |
"type": "function" | |
}, | |
{ | |
"inputs": [ | |
{ | |
"internalType": "address", | |
"name": "", | |
"type": "address" | |
}, | |
{ | |
"internalType": "uint256", | |
"name": "", | |
"type": "uint256" | |
} | |
], | |
"name": "CustomerLoans", | |
"outputs": [ | |
{ | |
"internalType": "string", | |
"name": "name", | |
"type": "string" | |
}, | |
{ | |
"internalType": "string", | |
"name": "date", | |
"type": "string" | |
}, | |
{ | |
"internalType": "uint256", | |
"name": "amount", | |
"type": "uint256" | |
}, | |
{ | |
"internalType": "address", | |
"name": "LenderAddress", | |
"type": "address" | |
}, | |
{ | |
"internalType": "address", | |
"name": "CustomerAddress", | |
"type": "address" | |
}, | |
{ | |
"internalType": "uint256", | |
"name": "OutstandingCredit", | |
"type": "uint256" | |
}, | |
{ | |
"internalType": "string", | |
"name": "IsOwnerOfThisLoan", | |
"type": "string" | |
} | |
], | |
"stateMutability": "view", | |
"type": "function" | |
}, | |
{ | |
"inputs": [ | |
{ | |
"internalType": "address", | |
"name": "", | |
"type": "address" | |
} | |
], | |
"name": "CustomerName", | |
"outputs": [ | |
{ | |
"internalType": "string", | |
"name": "", | |
"type": "string" | |
} | |
], | |
"stateMutability": "view", | |
"type": "function" | |
}, | |
{ | |
"inputs": [ | |
{ | |
"internalType": "address", | |
"name": "_address", | |
"type": "address" | |
} | |
], | |
"name": "GetCredit", | |
"outputs": [ | |
{ | |
"internalType": "uint256", | |
"name": "", | |
"type": "uint256" | |
} | |
], | |
"stateMutability": "view", | |
"type": "function" | |
}, | |
{ | |
"inputs": [ | |
{ | |
"internalType": "address", | |
"name": "_address", | |
"type": "address" | |
} | |
], | |
"name": "GetCreditLimit", | |
"outputs": [ | |
{ | |
"internalType": "uint256", | |
"name": "", | |
"type": "uint256" | |
} | |
], | |
"stateMutability": "view", | |
"type": "function" | |
}, | |
{ | |
"inputs": [ | |
{ | |
"internalType": "address", | |
"name": "_address", | |
"type": "address" | |
}, | |
{ | |
"internalType": "uint256", | |
"name": "_id", | |
"type": "uint256" | |
} | |
], | |
"name": "GetCustomerArray", | |
"outputs": [ | |
{ | |
"internalType": "string", | |
"name": "", | |
"type": "string" | |
}, | |
{ | |
"internalType": "string", | |
"name": "", | |
"type": "string" | |
}, | |
{ | |
"internalType": "uint256", | |
"name": "", | |
"type": "uint256" | |
}, | |
{ | |
"internalType": "uint256", | |
"name": "", | |
"type": "uint256" | |
}, | |
{ | |
"internalType": "address", | |
"name": "", | |
"type": "address" | |
}, | |
{ | |
"internalType": "address", | |
"name": "", | |
"type": "address" | |
} | |
], | |
"stateMutability": "view", | |
"type": "function" | |
}, | |
{ | |
"inputs": [ | |
{ | |
"internalType": "address", | |
"name": "_address", | |
"type": "address" | |
} | |
], | |
"name": "GetCustomerName", | |
"outputs": [ | |
{ | |
"internalType": "string", | |
"name": "", | |
"type": "string" | |
} | |
], | |
"stateMutability": "view", | |
"type": "function" | |
}, | |
{ | |
"inputs": [ | |
{ | |
"internalType": "address", | |
"name": "_address", | |
"type": "address" | |
}, | |
{ | |
"internalType": "uint256", | |
"name": "_id", | |
"type": "uint256" | |
} | |
], | |
"name": "GetLenderArray", | |
"outputs": [ | |
{ | |
"internalType": "string", | |
"name": "", | |
"type": "string" | |
}, | |
{ | |
"internalType": "string", | |
"name": "", | |
"type": "string" | |
}, | |
{ | |
"internalType": "uint256", | |
"name": "", | |
"type": "uint256" | |
}, | |
{ | |
"internalType": "uint256", | |
"name": "", | |
"type": "uint256" | |
}, | |
{ | |
"internalType": "address", | |
"name": "", | |
"type": "address" | |
}, | |
{ | |
"internalType": "address", | |
"name": "", | |
"type": "address" | |
} | |
], | |
"stateMutability": "view", | |
"type": "function" | |
}, | |
{ | |
"inputs": [ | |
{ | |
"internalType": "address", | |
"name": "_address", | |
"type": "address" | |
} | |
], | |
"name": "GetLenderCount", | |
"outputs": [ | |
{ | |
"internalType": "uint256", | |
"name": "count", | |
"type": "uint256" | |
} | |
], | |
"stateMutability": "view", | |
"type": "function" | |
}, | |
{ | |
"inputs": [ | |
{ | |
"internalType": "address", | |
"name": "_address", | |
"type": "address" | |
} | |
], | |
"name": "GetLenderName", | |
"outputs": [ | |
{ | |
"internalType": "string", | |
"name": "", | |
"type": "string" | |
} | |
], | |
"stateMutability": "view", | |
"type": "function" | |
}, | |
{ | |
"inputs": [ | |
{ | |
"internalType": "uint256", | |
"name": "_id", | |
"type": "uint256" | |
} | |
], | |
"name": "GetMyArray", | |
"outputs": [ | |
{ | |
"internalType": "string", | |
"name": "", | |
"type": "string" | |
}, | |
{ | |
"internalType": "string", | |
"name": "", | |
"type": "string" | |
}, | |
{ | |
"internalType": "uint256", | |
"name": "", | |
"type": "uint256" | |
}, | |
{ | |
"internalType": "uint256", | |
"name": "", | |
"type": "uint256" | |
}, | |
{ | |
"internalType": "address", | |
"name": "", | |
"type": "address" | |
}, | |
{ | |
"internalType": "address", | |
"name": "", | |
"type": "address" | |
} | |
], | |
"stateMutability": "view", | |
"type": "function" | |
}, | |
{ | |
"inputs": [], | |
"name": "GetMyName", | |
"outputs": [ | |
{ | |
"internalType": "string", | |
"name": "", | |
"type": "string" | |
} | |
], | |
"stateMutability": "view", | |
"type": "function" | |
}, | |
{ | |
"inputs": [ | |
{ | |
"internalType": "address", | |
"name": "_address", | |
"type": "address" | |
}, | |
{ | |
"internalType": "uint256", | |
"name": "_amount", | |
"type": "uint256" | |
} | |
], | |
"name": "IncreaseCurrentCredit", | |
"outputs": [], | |
"stateMutability": "nonpayable", | |
"type": "function" | |
}, | |
{ | |
"inputs": [ | |
{ | |
"internalType": "address", | |
"name": "", | |
"type": "address" | |
} | |
], | |
"name": "IsAdmin", | |
"outputs": [ | |
{ | |
"internalType": "bool", | |
"name": "", | |
"type": "bool" | |
} | |
], | |
"stateMutability": "view", | |
"type": "function" | |
}, | |
{ | |
"inputs": [ | |
{ | |
"internalType": "address", | |
"name": "", | |
"type": "address" | |
} | |
], | |
"name": "IsLender", | |
"outputs": [ | |
{ | |
"internalType": "bool", | |
"name": "", | |
"type": "bool" | |
} | |
], | |
"stateMutability": "view", | |
"type": "function" | |
}, | |
{ | |
"inputs": [ | |
{ | |
"internalType": "address", | |
"name": "", | |
"type": "address" | |
} | |
], | |
"name": "IsOwner", | |
"outputs": [ | |
{ | |
"internalType": "bool", | |
"name": "", | |
"type": "bool" | |
} | |
], | |
"stateMutability": "view", | |
"type": "function" | |
}, | |
{ | |
"inputs": [ | |
{ | |
"internalType": "address", | |
"name": "", | |
"type": "address" | |
} | |
], | |
"name": "LenderName", | |
"outputs": [ | |
{ | |
"internalType": "string", | |
"name": "", | |
"type": "string" | |
} | |
], | |
"stateMutability": "view", | |
"type": "function" | |
}, | |
{ | |
"inputs": [ | |
{ | |
"internalType": "uint256", | |
"name": "", | |
"type": "uint256" | |
} | |
], | |
"name": "Loans", | |
"outputs": [ | |
{ | |
"internalType": "string", | |
"name": "name", | |
"type": "string" | |
}, | |
{ | |
"internalType": "string", | |
"name": "date", | |
"type": "string" | |
}, | |
{ | |
"internalType": "uint256", | |
"name": "amount", | |
"type": "uint256" | |
}, | |
{ | |
"internalType": "address", | |
"name": "LenderAddress", | |
"type": "address" | |
}, | |
{ | |
"internalType": "address", | |
"name": "CustomerAddress", | |
"type": "address" | |
}, | |
{ | |
"internalType": "uint256", | |
"name": "OutstandingCredit", | |
"type": "uint256" | |
}, | |
{ | |
"internalType": "string", | |
"name": "IsOwnerOfThisLoan", | |
"type": "string" | |
} | |
], | |
"stateMutability": "view", | |
"type": "function" | |
}, | |
{ | |
"inputs": [ | |
{ | |
"internalType": "address", | |
"name": "", | |
"type": "address" | |
}, | |
{ | |
"internalType": "uint256", | |
"name": "", | |
"type": "uint256" | |
} | |
], | |
"name": "LoansIssued", | |
"outputs": [ | |
{ | |
"internalType": "string", | |
"name": "name", | |
"type": "string" | |
}, | |
{ | |
"internalType": "string", | |
"name": "date", | |
"type": "string" | |
}, | |
{ | |
"internalType": "uint256", | |
"name": "amount", | |
"type": "uint256" | |
}, | |
{ | |
"internalType": "address", | |
"name": "LenderAddress", | |
"type": "address" | |
}, | |
{ | |
"internalType": "address", | |
"name": "CustomerAddress", | |
"type": "address" | |
}, | |
{ | |
"internalType": "uint256", | |
"name": "OutstandingCredit", | |
"type": "uint256" | |
}, | |
{ | |
"internalType": "string", | |
"name": "IsOwnerOfThisLoan", | |
"type": "string" | |
} | |
], | |
"stateMutability": "view", | |
"type": "function" | |
}, | |
{ | |
"inputs": [ | |
{ | |
"internalType": "address", | |
"name": "_address", | |
"type": "address" | |
}, | |
{ | |
"internalType": "uint256", | |
"name": "_amount", | |
"type": "uint256" | |
}, | |
{ | |
"internalType": "uint256", | |
"name": "_CustomerArrayNumber", | |
"type": "uint256" | |
}, | |
{ | |
"internalType": "uint256", | |
"name": "_LenderArrayNumber", | |
"type": "uint256" | |
} | |
], | |
"name": "PaidOffCredit", | |
"outputs": [], | |
"stateMutability": "nonpayable", | |
"type": "function" | |
}, | |
{ | |
"inputs": [ | |
{ | |
"internalType": "address", | |
"name": "_address", | |
"type": "address" | |
} | |
], | |
"name": "SetAdmin", | |
"outputs": [], | |
"stateMutability": "nonpayable", | |
"type": "function" | |
}, | |
{ | |
"inputs": [ | |
{ | |
"internalType": "address", | |
"name": "_address", | |
"type": "address" | |
}, | |
{ | |
"internalType": "uint256", | |
"name": "_amount", | |
"type": "uint256" | |
} | |
], | |
"name": "SetCreditLimit", | |
"outputs": [], | |
"stateMutability": "nonpayable", | |
"type": "function" | |
}, | |
{ | |
"inputs": [ | |
{ | |
"internalType": "address", | |
"name": "_address", | |
"type": "address" | |
}, | |
{ | |
"internalType": "string", | |
"name": "_Name", | |
"type": "string" | |
} | |
], | |
"name": "SetCustomerName", | |
"outputs": [], | |
"stateMutability": "nonpayable", | |
"type": "function" | |
}, | |
{ | |
"inputs": [ | |
{ | |
"internalType": "address", | |
"name": "_address", | |
"type": "address" | |
} | |
], | |
"name": "SetLender", | |
"outputs": [], | |
"stateMutability": "nonpayable", | |
"type": "function" | |
}, | |
{ | |
"inputs": [ | |
{ | |
"internalType": "address", | |
"name": "_address", | |
"type": "address" | |
}, | |
{ | |
"internalType": "string", | |
"name": "_Name", | |
"type": "string" | |
} | |
], | |
"name": "SetLenderName", | |
"outputs": [], | |
"stateMutability": "nonpayable", | |
"type": "function" | |
}, | |
{ | |
"inputs": [ | |
{ | |
"internalType": "string", | |
"name": "a", | |
"type": "string" | |
}, | |
{ | |
"internalType": "string", | |
"name": "b", | |
"type": "string" | |
} | |
], | |
"name": "compareStrings", | |
"outputs": [ | |
{ | |
"internalType": "bool", | |
"name": "", | |
"type": "bool" | |
} | |
], | |
"stateMutability": "view", | |
"type": "function" | |
}, | |
{ | |
"inputs": [ | |
{ | |
"internalType": "address", | |
"name": "_address", | |
"type": "address" | |
} | |
], | |
"name": "getCount", | |
"outputs": [ | |
{ | |
"internalType": "uint256", | |
"name": "count", | |
"type": "uint256" | |
} | |
], | |
"stateMutability": "view", | |
"type": "function" | |
}, | |
{ | |
"inputs": [ | |
{ | |
"internalType": "address", | |
"name": "x", | |
"type": "address" | |
} | |
], | |
"name": "toString", | |
"outputs": [ | |
{ | |
"internalType": "string", | |
"name": "", | |
"type": "string" | |
} | |
], | |
"stateMutability": "nonpayable", | |
"type": "function" | |
}, | |
{ | |
"inputs": [ | |
{ | |
"internalType": "address", | |
"name": "_address", | |
"type": "address" | |
}, | |
{ | |
"internalType": "string", | |
"name": "_Name", | |
"type": "string" | |
}, | |
{ | |
"internalType": "string", | |
"name": "_Date", | |
"type": "string" | |
}, | |
{ | |
"internalType": "uint256", | |
"name": "_Amount", | |
"type": "uint256" | |
} | |
], | |
"name": "updateArray", | |
"outputs": [], | |
"stateMutability": "nonpayable", | |
"type": "function" | |
} | |
]; | |
Contract = new web3js.eth.Contract(abi, address); | |
}) | |
//Get details portion , Credit limit, credit details , credit amount used of customer. | |
$('#GetCount').click(function () { | |
var address = $('#GetDetailsAddress').val(); | |
Contract.methods.getCount(address).call().then(function (bal) { | |
$('#ArrayCount').html(bal); | |
}) | |
var address = $('#GetDetailsAddress').val(); | |
Contract.methods.GetCredit(address).call().then(function (Cred) { | |
$('#CreditUsage').html(Cred); | |
}) | |
var address = $('#GetDetailsAddress').val(); | |
Contract.methods.GetCreditLimit(address).call().then(function (Lim) { | |
$('#CreditLimit').html(Lim); | |
}) | |
var address = $('#GetDetailsAddress').val(); | |
Contract.methods.GetCustomerName(address).call().then(function (Name) { | |
$('#CustomerName').html(Name); | |
}) | |
}) | |
$('#SetArray').click(function () { | |
var address = $('#customeraddress').val(); | |
var name = $('#lname').val(); | |
var date = $('#ldate').val(); | |
var amount = $('#lamount').val(); | |
console.log(address, name, date, amount, lname); | |
web3js.eth.getAccounts().then(function (accounts) { | |
var acc = accounts[0]; | |
//var address = $('#address').val(); | |
//var address = $('#name').val(); | |
//var address = $('#date').val(); | |
// var address = $('#amount').val(); | |
// var address = $('#lname').val(); | |
return Contract.methods.updateArray(address, name, date, amount).send({ from: acc }); | |
}).then(function (tx) { | |
console.log(tx); | |
}).catch(function (tx) { | |
console.log(tx); | |
}) | |
}) | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment