Skip to content

Commit

Permalink
fix: solved bug when patching volunteer by id
Browse files Browse the repository at this point in the history
  • Loading branch information
fabian-urner committed Mar 13, 2024
1 parent c0d98b6 commit b7abab4
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions src/main/java/dev/urner/volodb/service/VolunteerServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import java.lang.reflect.Field;
import java.time.LocalDate;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -69,16 +70,25 @@ public Volunteer update(int theVolunteerId, Map<String, Object> fields) {
return;

// Person
switch (key.toLowerCase()) {
case "lastname":
dbVolunteer.getPerson().setLastname(value.toString());
return;
case "firstname":
dbVolunteer.getPerson().setFirstname(value.toString());
return;
case "gender":
dbVolunteer.getPerson().setGender(new Gender(value.toString()));
return;
if (key.toLowerCase() == "person") {
Map<String, Object> personMap = (Map<String, Object>) value;
personMap.forEach((pKey, pValue) -> {
switch (pKey) {
case "lastname":
dbVolunteer.getPerson().setLastname(pValue.toString());
return;

case "firstname":
dbVolunteer.getPerson().setFirstname(pValue.toString());
return;

case "gender":
dbVolunteer.getPerson().setGender(new Gender(pValue.toString()));
return;
}
});
return;

}

// VolunteerStatus
Expand Down

0 comments on commit b7abab4

Please sign in to comment.