diff --git a/Moonlight/App/Services/ServiceManage/ServiceAdminService.cs b/Moonlight/App/Services/ServiceManage/ServiceAdminService.cs index d189f24c..2fe7b46e 100644 --- a/Moonlight/App/Services/ServiceManage/ServiceAdminService.cs +++ b/Moonlight/App/Services/ServiceManage/ServiceAdminService.cs @@ -75,7 +75,7 @@ public class ServiceAdminService await Actions[service.Product.Type].Delete(scope.ServiceProvider, service); - foreach (var share in service.Shares) + foreach (var share in service.Shares.ToArray()) { serviceShareRepo.Delete(share); } diff --git a/Moonlight/App/Services/Users/UserDeleteService.cs b/Moonlight/App/Services/Users/UserDeleteService.cs index b3dd8756..c9ce8daa 100644 --- a/Moonlight/App/Services/Users/UserDeleteService.cs +++ b/Moonlight/App/Services/Users/UserDeleteService.cs @@ -104,6 +104,9 @@ public class UserDeleteService TransactionRepository.Delete(transaction); // User - UserRepository.Delete(user); + + // We need to use this in order to entity framework not crashing because of the previous deleted data + var userToDelete = UserRepository.Get().First(x => x.Id == user.Id); + UserRepository.Delete(userToDelete); } } \ No newline at end of file