aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/com/encora/Main.java13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/main/java/com/encora/Main.java b/src/main/java/com/encora/Main.java
index 108e657..97ad25f 100644
--- a/src/main/java/com/encora/Main.java
+++ b/src/main/java/com/encora/Main.java
@@ -70,4 +70,17 @@ public class Main {
selectedToDo.setDoneDate(new Date());
toDosRepository.save(selectedToDo);
}
+
+ // Update a to do to set "done" as false.
+ @PutMapping("/todos/{id}/undone")
+ @ResponseStatus(value=HttpStatus.OK)
+ public void setUndone(@PathVariable("id") Integer id) {
+ ToDos selectedToDo = toDosRepository.getById(id);
+ if (selectedToDo == null) throw new toDoNotFound();
+ if (!selectedToDo.isDone()) return;
+
+ selectedToDo.setDone(false);
+ selectedToDo.setDoneDate(null);
+ toDosRepository.save(selectedToDo);
+ }
}