using Bit.SeederApi.Commands.Interfaces; namespace Bit.SeederApi.Commands; public class DestroyBatchScenesCommand( ILogger logger, IDestroySceneCommand destroySceneCommand) : IDestroyBatchScenesCommand { public async Task DestroyAsync(IEnumerable playIds) { var exceptions = new List(); var deleteTasks = playIds.Select(async playId => { try { await destroySceneCommand.DestroyAsync(playId); } catch (Exception ex) { lock (exceptions) { exceptions.Add(ex); } logger.LogError(ex, "Error deleting seeded data: {PlayId}", playId); } }); await Task.WhenAll(deleteTasks); if (exceptions.Count > 0) { throw new AggregateException("One or more errors occurred while deleting seeded data", exceptions); } } }