aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdrián Oliva <adrian.oliva@cimat.mx>2023-05-25 19:35:12 -0600
committerAdrián Oliva <adrian.oliva@cimat.mx>2023-05-25 19:35:12 -0600
commite366121acd2aeefd3ce70fd07c09d2bdbcfeb56b (patch)
treec73548abe033ad6d2ea46f5c72a7e02c5892af99 /src
parentf48cf17ecedade7502c4d09f6f7a90e84f3776f3 (diff)
downloadToDo-App-BE-e366121acd2aeefd3ce70fd07c09d2bdbcfeb56b.tar.gz
ToDo-App-BE-e366121acd2aeefd3ce70fd07c09d2bdbcfeb56b.zip
New PUT to set undone.
PUT request on path /todos/{id}/undone sets the to do with id {id} to undone. It also resets the 'doneDate' variable.
Diffstat (limited to 'src')
-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);
+ }
}