diff --git a/src/main/java/com/MeetMate/company/CompanyService.java b/src/main/java/com/MeetMate/company/CompanyService.java index ec425cc..414a18e 100644 --- a/src/main/java/com/MeetMate/company/CompanyService.java +++ b/src/main/java/com/MeetMate/company/CompanyService.java @@ -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); }