-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathback up.sol
47 lines (40 loc) · 2 KB
/
back up.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
function getDriver(uint _driverId) public view returns(uint, address, string, string, uint){
uberDriver storage uberdriver = uberdrivers[_driverId];
return(_driverId, uberdriver.driverAddress, uberdriver.name, uberdriver.car, uberdriver.rating);
}
function getAllDrivers() external view returns(uint[]){
uint[] memory result;
uint counter = 0;
for (uint i = 0; i < uberdrivers.length; i++) {
result[counter] = i;
counter++;
}
return result;
}
function requestToBeDriver(string _car, string _name) public returns(string){
numberOfDrivers++;
uberdrivers[numberOfDrivers] = uberDriver(msg.sender,0, _name, _car, DriverStatus.Requested);
// emit DriverAccessRequested(msg.sender, "Requested");
}
function reviewDriver(uint _driverID, address _driverAddress, string _returnStatus) onlyOwner public{
string memory message;
if(keccak256(_returnStatus) == keccak256("Approved"))
{
uberdrivers[_driverID].status = DriverStatus.Registered;
message = "Successfully registered, you can start driving";
}else if(keccak256(_returnStatus) == keccak256("Pending")){
uberdrivers[_driverID].status = DriverStatus.Pending;
message = "We need some more time. Thanks";
}else if(keccak256(_returnStatus) == keccak256("Rejected")){
uberdrivers[_driverID].status = DriverStatus.Failed;
message = "Sorry, you don't meet our conditions";
}else{
uberdrivers[_driverID].status = DriverStatus.NotRegistered;
message = "Still not registred";
}
// emit DriverAccessReviewed(_driverAddress, message);
}
function rateDriver(uint _driverId, uint rating) public isUberContract(msg.sender){
uberdrivers[_driverId].rating = uberdrivers[_driverId].rating + rating;
// emit DriverRated(_driverId, uberdrivers[_driverId].rating);
}