public async Task DeleteResource(Guid resourceId) { var cyclicOperations = _cyclicOperationRepository.GetAll().Where(r => r.ResourceId == resourceId); var operations = _operationRepository.GetAll().Where(r => r.ResourceId == resourceId); if (cyclicOperations.Any()) { await _cyclicOperationRepository.DeleteBulk(cyclicOperations); } if (operations.Any()) { await _operationRepository.DeleteBulk(operations); } await _repository.Delete(await _repository.Get(resourceId) ?? throw new ArgumentException("Resource not found")); }