public async Task DeleteManyAsync(IEnumerable <Guid> cipherIds, Guid deletingUserId, Guid?organizationId = null, bool orgAdmin = false) { var cipherIdsSet = new HashSet <Guid>(cipherIds); var deletingCiphers = new List <Cipher>(); if (orgAdmin && organizationId.HasValue) { var ciphers = await _cipherRepository.GetManyByOrganizationIdAsync(organizationId.Value); deletingCiphers = ciphers.Where(c => cipherIdsSet.Contains(c.Id)).ToList(); await _cipherRepository.DeleteByIdsOrganizationIdAsync(deletingCiphers.Select(c => c.Id), organizationId.Value); } else { var ciphers = await _cipherRepository.GetManyByUserIdAsync(deletingUserId); deletingCiphers = ciphers.Where(c => cipherIdsSet.Contains(c.Id) && c.Edit).Select(x => (Cipher)x).ToList(); await _cipherRepository.DeleteAsync(deletingCiphers.Select(c => c.Id), deletingUserId); } var events = deletingCiphers.Select(c => new Tuple <Cipher, EventType, DateTime?>(c, EventType.Cipher_Deleted, null)); foreach (var eventsBatch in events.Batch(100)) { await _eventService.LogCipherEventsAsync(eventsBatch); } // push await _pushService.PushSyncCiphersAsync(deletingUserId); }