From 99a047f55dde7a9c051250792a466b7db47cff21 Mon Sep 17 00:00:00 2001 From: Shreyanshi210205 Date: Sat, 30 Mar 2024 14:34:35 +0530 Subject: [PATCH] feat: added the modifier in addPerson function --- contract/Database.sol | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/contract/Database.sol b/contract/Database.sol index 99899cb..962c90d 100644 --- a/contract/Database.sol +++ b/contract/Database.sol @@ -7,23 +7,30 @@ contract Database{ string name; string DOB; string phoneNo; - - } + +} mapping( uint256=> Details) public list; - + mapping (string => bool) public added; uint256 public count=0; constructor() { } - - function addPerson(string calldata aadharId,string calldata name, string calldata DOB, string calldata phoneNo) public + modifier Added (string memory aadhar) + { + require(!added[aadhar],"Details already added"); + _; + } + + function addPerson(string calldata aadharId,string calldata name, string calldata DOB, string calldata phoneNo ) public Added (aadharId) { Details memory person = Details({aadharId: aadharId,name: name,DOB: DOB,phoneNo: phoneNo}); list[count]=person; + added[aadharId]=true; count++; } +