Skip to content

Commit

Permalink
Fix relevant classes for updating fields
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-setyawan committed Mar 26, 2024
1 parent ab3acd2 commit faf94c4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
16 changes: 12 additions & 4 deletions src/main/java/seedu/address/logic/commands/UpdateCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,12 @@ public CommandResult execute(Model model) throws CommandException {
requireNonNull(model);
List<Person> lastShownList = model.getFilteredPersonList();

Person personToUpdate = null;
if (!model.hasPerson(Person.createPersonWithNric(nric))) {
throw new CommandException(Messages.MESSAGE_PERSON_NOT_FOUND);
}
personToUpdate = lastShownList.stream().filter(new NricContainsKeywordsPredicate(nric.toString()))
.findFirst().get();

Person personToUpdate = lastShownList.stream().filter(
new NricContainsKeywordsPredicate(nric.toString())).findFirst().get();
Person updatedPerson = createUpdatedPerson(personToUpdate, updatePersonDescriptor);

if (!personToUpdate.isSamePerson(updatedPerson) && model.hasPerson(updatedPerson)) {
Expand Down Expand Up @@ -200,7 +199,16 @@ public UpdatePersonDescriptor(UpdatePersonDescriptor toCopy) {
setDateOfBirth(toCopy.dateOfBirth);
setSex(toCopy.sex);
setStatus(toCopy.status);
setTags(toCopy.tags);

setEmail(toCopy.email);
setCountry(toCopy.country);

setAllergies(toCopy.allergies);
setBloodType(toCopy.bloodType);
setCondition(toCopy.condition);
setDateOfAdmission(toCopy.dateOfAdmission);
setDiagnosis(toCopy.diagnosis);
setSymptom(toCopy.symptom);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ public UpdateCommand parse(String args) throws ParseException {
if (argMultimap.getValue(PREFIX_SYMPTOM).isPresent()) {
updatePersonDescriptor.setSymptom(ParserUtil.parseSymptom(argMultimap.getValue(PREFIX_SYMPTOM).get()));
}
parseTagsForEdit(argMultimap.getAllValues(PREFIX_TAG)).ifPresent(updatePersonDescriptor::setTags);

// parseTagsForEdit(argMultimap.getAllValues(PREFIX_TAG)).ifPresent(updatePersonDescriptor::setTags);

if (!updatePersonDescriptor.isAnyFieldUpdated()) {
throw new ParseException(UpdateCommand.MESSAGE_NOT_UPDATED);
Expand Down

0 comments on commit faf94c4

Please sign in to comment.