Skip to content

Commit

Permalink
Now deletes all company members when deleting a company
Browse files Browse the repository at this point in the history
  • Loading branch information
Gugi-Games committed Oct 24, 2024
1 parent ddbaeb7 commit c4e2621
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/main/java/com/MeetMate/company/CompanyService.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@ public void deleteCompany(String token) {
} catch (Throwable t) {
throw new MongoTransactionException("Could not delete company owner");
}

try {
for (Long memberId : company.getMemberIds())
userRepository.deleteById(memberId);
} catch (Throwable t) {
throw new MongoTransactionException("Could not delete company members");
}
companyRepository.delete(company);
}

Expand Down

0 comments on commit c4e2621

Please sign in to comment.