Skip to content

Commit

Permalink
Update ContactController.java
Browse files Browse the repository at this point in the history
  • Loading branch information
BettyB979 committed Nov 24, 2023
1 parent 44b19a1 commit 2f26c14
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import fr.insee.survey.datacollectionmanagement.contact.dto.ContactFirstLoginDto;
import fr.insee.survey.datacollectionmanagement.contact.service.AddressService;
import fr.insee.survey.datacollectionmanagement.contact.service.ContactService;
import fr.insee.survey.datacollectionmanagement.exception.NotFoundException;
import fr.insee.survey.datacollectionmanagement.questioning.domain.Questioning;
import fr.insee.survey.datacollectionmanagement.questioning.domain.QuestioningAccreditation;
import fr.insee.survey.datacollectionmanagement.questioning.service.QuestioningAccreditationService;
Expand Down Expand Up @@ -133,7 +134,12 @@ public ResponseEntity<?> putContact(@PathVariable("id") String id, @RequestBody
}
if (contactDto.getAddress() != null)
contact.setAddress(addressService.convertToEntity(contactDto.getAddress()));
Contact contactUpdate = contactService.updateContactAddressEvent(contact, null);
Contact contactUpdate = null;
try {
contactUpdate = contactService.updateContactAddressEvent(contact, null);
} catch (NotFoundException e) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Error when update contact");
}
return ResponseEntity.ok().headers(responseHeaders).body(convertToDto(contactUpdate));
}

Expand Down

0 comments on commit 2f26c14

Please sign in to comment.