public async Task DeleteTenantDependencyAsync(string tenantId) { var companies = await _companyRepository.GetAll().Where(x => x.TenantId == tenantId).ToListAsync(); _companyRepository.TrashAll(companies); var payments = await _subscriptionPaymentRepository.GetAll() .Where(x => x.TenantId == tenantId && x.PaymentStatus != SubscriptionPaymentStatus.Paid && x.PaymentStatus != SubscriptionPaymentStatus.AwaitingConfirmation) .ToListAsync(); _subscriptionPaymentRepository.TrashAll(payments); var subscriptions = await _subscriptionRepository.GetAll().Where(x => x.TenantId == tenantId).ToListAsync(); _subscriptionRepository.TrashAll(subscriptions); var branches = await _branchRepository.GetAll().Where(x => x.TenantId == tenantId).ToListAsync(); _branchRepository.TrashAll(branches); await _subscriptionRepository.CommitAsync(); await _subscriptionPaymentRepository.CommitAsync(); await _companyRepository.CommitAsync(); await _branchRepository.CommitAsync(); #region Security var users = _userService.GetUsersByTenantId(tenantId); foreach (var user in users) { await _userService.DeleteUserAsync(user); } #endregion }