Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- contract EmployeeStore is Restricted{
- uint public employeesCount;
- enum authenticationStatus {Active, Inactive}
- struct employee {
- address account;
- string name;
- string employeeID;
- authenticationStatus access;
- }
- mapping (uint => employee) employees;
- mapping (address => uint) employeeAddressIndex;
- mapping (string => uint) employeeNameIndex;
- mapping (string => uint) employeeIDIndex;
- event NewAuthenticationEvent(uint indexed id, address indexed employee, uint timestamp);
- event UpdateEmployeeEvent(uint indexed id, address indexed employee, uint timestamp);
- event RemoveAuthenticationEvent(uint indexed id, address indexed employee, uint timestamp);
- function EmployeeStore(string name, string employeeID) public {
- employeesCount = 0;
- employees[employeesCount] = employee(admin, name, employeeID, authenticationStatus.Active);
- employeeAddressIndex[admin] = employeesCount;
- employeeNameIndex[name] = employeesCount;
- employeeIDIndex[employeeID] = employeesCount;
- }
- function hasAccessByAddress(address account) external constant returns(bool) {
- if(employees[employeeAddressIndex[account]].access == authenticationStatus.Active){
- return true;
- } else return false;
- }
- function gotAccess(address account) public constant returns(authenticationStatus) {
- return employees[employeeAddressIndex[account]].access;
- }
- function newEmployee(address account, string name, string employeeID) public {
- employeesCount++;
- employees[employeesCount] = employee(account, name, employeeID, authenticationStatus.Active);
- employeeAddressIndex[account] = employeesCount;
- employeeNameIndex[name] = employeesCount;
- employeeIDIndex[employeeID] = employeesCount;
- emit NewAuthenticationEvent(employeesCount, account, now);
- }
Add Comment
Please, Sign In to add comment