public async Task <ListadeFundos> ListarInvestimentosFundos(string id, CancellationToken ct) { var cache = await _redisClient.RecuperarCache("Fundos-" + id); if (cache != null) { return(cache); } var result = await _fundosService.ListarInvestimentosFundos(id, ct); await _redisClient.SalvarCache("Fundos-" + id, result, DateTimeOffset.Now.Add(new TimeSpan(23, 59, 59))); return(result); }
public async Task <ListaInvestimentos> Handle(ConsultarValorTotalInvestidoQuery request, CancellationToken cancellationToken) { var fundosServiceResult = await _fundosService.ListarInvestimentosFundos(_servicesOptions.FundosId, cancellationToken); var rendaFixaServiceResult = await _rendaFixaService.ListarInvestimentosRendaFixa(_servicesOptions.RendaFixaId, cancellationToken); var tesouroDiretoServiceResult = await _tesouroDiretoService.ListarInvestimentosTesouroDireto(_servicesOptions.TesouroDiretoId, cancellationToken); var result = new ListaInvestimentos(); List <Investimento> listaInvestimentos = new List <Investimento>(); listaInvestimentos.AddRange(fundosServiceResult?.fundos); listaInvestimentos.AddRange(rendaFixaServiceResult?.lcis); listaInvestimentos.AddRange(tesouroDiretoServiceResult?.tds); result.Investimentos.AddRange(listaInvestimentos); result.ValorTotal = listaInvestimentos.Sum(t => t.ValorResgate); return(result); }