Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]: A user can update the details #16

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 24 additions & 6 deletions contract/Database.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@ contract Database{
}


}




mapping( address => Details) public list;

mapping( uint256=> Details) public list;
mapping (string => bool) public added;

uint256 public count=0;
address public admin;
bool alreadyset=false;
Expand All @@ -28,8 +31,13 @@ contract Database{
}


function addPerson(string memory aadharId,string memory name, string memory DOB, string memory phoneNo, string memory rollNo, string memory batchNo) public
modifier personPresent{
require(keccak256(abi.encodePacked(list[msg.sender].aadharId)) != keccak256(abi.encodePacked("")), "Person doesn't exist");
_;
}



modifier Added (string memory aadhar)
{
require(!added[aadhar],"Details already added");
Expand All @@ -56,17 +64,27 @@ contract Database{

}

function addPerson(string calldata aadharId,string calldata name, string calldata DOB, string calldata phoneNo ) public Added (aadharId)
function addPerson(string memory aadharId,string memory name, string memory DOB, string memory phoneNo, string memory rollNo, string memory batchNo) public Added (aadharId)

{
Details memory person = Details({aadharId: aadharId,name: name,DOB: DOB,phoneNo: phoneNo, rollNo: rollNo, batchNo: batchNo});
list[count]=person;
list[msg.sender]=person;
added[aadharId]=true;

count++;
}



function updateDetails(string memory aadharId,string memory name, string memory DOB, string memory phoneNo, string memory rollNo, string memory batchNo)public personPresent{
Details storage person = list[msg.sender];
person.aadharId = aadharId;
person.name = name;
person.DOB = DOB;
person.phoneNo = phoneNo;
person.rollNo = rollNo;
person.batchNo = batchNo;
added[aadharId]=true;
}



Expand Down
Loading