Last active
April 23, 2021 15:45
-
-
Save mihairadulescu/ba3ec073479e79f0d3e74fc33a291585 to your computer and use it in GitHub Desktop.
Contract Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.8.3; | |
import "./Model.sol"; | |
contract Task { | |
Model.Task task; | |
mapping(address=> Model.Task[]) tasks; | |
event TaskStarted (address indexed owner, Model.Task task); | |
event TaskStopped (address indexed owner, Model.Task task); | |
function start(Model.CreateTask calldata _task) public { | |
Model.Task memory _newTask = Model.Task(_task.Title, | |
_task.Description, | |
block.timestamp, | |
0, | |
Model.TaskStatus.Started, | |
msg.sender); | |
tasks[msg.sender].push(_newTask); | |
emit TaskStarted(msg.sender, _newTask); | |
} | |
function getTask(uint taskNumber) public view returns(Model.Task memory){ | |
return tasks[msg.sender][taskNumber]; | |
} | |
function end(uint taskNumber) public { | |
tasks[msg.sender][taskNumber].Status = Model.TaskStatus.Ended; | |
tasks[msg.sender][taskNumber].EndDate = block.timestamp; | |
emit TaskStopped(msg.sender, tasks[msg.sender][taskNumber]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment