using back.Entities.DTOs.Response; using back.Entities; using back.Application.Contracts.Services; using back.Application.Contracts.Persistence; namespace back.Application.Services { public class WantItAllService : IWantItAllService { private readonly IAsyncRepository personaRepo; private readonly IAsyncRepository casaRepo; private readonly IAsyncRepository direccionRepo; public WantItAllService(IAsyncRepository personaRepo, IAsyncRepository casaRepo, IAsyncRepository direccionRepo) { this.personaRepo = personaRepo; this.casaRepo = casaRepo; this.direccionRepo = direccionRepo; } public async Task GetWithAsyncAwait() { var personas = await personaRepo.GetAllAsync(); var casas = await casaRepo.GetAllAsync(); var direcciones = await direccionRepo.GetAllAsync(); var toReturn = new IWantItAll { Personas = personas.ToList(), Casas = casas.ToList(), Direcciones = direcciones.ToList(), }; return toReturn; } public async Task GetWithTasks() { var personas = personaRepo.GetAllAsync(); var casas = casaRepo.GetAllAsync(); var direcciones = direccionRepo.GetAllAsync(); await Task.WhenAll(personas, casas, direcciones); IReadOnlyList personas1 = await personas; IReadOnlyList casas1 = await casas; IReadOnlyList direccions = await direcciones; var toReturn = new IWantItAll { Personas = personas1.ToList(), Casas = casas1.ToList(), Direcciones = direccions.ToList(), }; return toReturn; } } }