namespace RackPeek.Domain.Resources.SystemResources.UseCases; public sealed class SystemSummary { public SystemSummary( int totalSystems, IReadOnlyDictionary systemsByType, IReadOnlyDictionary systemsByOs) { TotalSystems = totalSystems; SystemsByType = systemsByType; SystemsByOs = systemsByOs; } public int TotalSystems { get; } public IReadOnlyDictionary SystemsByType { get; } public IReadOnlyDictionary SystemsByOs { get; } } public class GetSystemSummaryUseCase(ISystemRepository repository) : IUseCase { public async Task ExecuteAsync() { var totalSystemsTask = repository.GetSystemCountAsync(); var systemsByTypeTask = repository.GetSystemTypeCountAsync(); var systemsByOsTask = repository.GetSystemOsCountAsync(); await Task.WhenAll( totalSystemsTask, systemsByTypeTask, systemsByOsTask ); return new SystemSummary( totalSystemsTask.Result, systemsByTypeTask.Result, systemsByOsTask.Result ); } }