-
Notifications
You must be signed in to change notification settings - Fork 0
/
persons.sol
55 lines (45 loc) · 1.07 KB
/
persons.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
pragma solidity ^0.4.17;
contract toDoList
{
address owner;
uint id;
string name;
uint count = 0;
uint index = 1111111111111111111;
mapping (uint => person) Person;
event getPersonDetails(uint , uint, string);
struct person
{
uint _index;
uint _id;
string _name;
}
constructor() public
{
owner = msg.sender;
}
modifier isowner()
{
require(msg.sender==owner, "Hey, You are not ADMIN!");
_;
}
function addPerson(string memory _name) public isowner
{
Person[count] = person(index, count, _name);
emit getPersonDetails(index, count, _name);
count++;
index++;
}
function getPerson(uint _id) public view returns(uint, uint, string)
{
return (Person[_id]._index, Person[_id]._id, Person[_id]._name);
}
function getCount() public view returns(uint)
{
return count;
}
function deletePerson(uint _id) public isowner
{
delete Person[_id];
}
}