public InvestimentoModel Map(FundoModel model) { try { if (model is null) { _logger.LogInformation("Parametro do tipo {type} nulo. Method: {method}", nameof(FundoModel), nameof(Map)); return(default);
private async Task ValidateMapObject(FundoModel fundo, InvestimentoModel investimento) { if (fundo is null) { investimento.Should().BeNull(); } else if (investimento is null) { investimento.Should().BeNull(); } else { investimento.Nome.Should().Be(fundo.Nome); investimento.ValorInvestido.Should().Be(fundo.CapitalInvestido); investimento.ValorTotal.Should().Be(fundo.ValorAtual); investimento.Vencimento.Should().Be(fundo.DataResgate); investimento.Ir.Should().Be(fundo.Ir); investimento.ValorResgate.Should().Be(fundo.ValorResgate); } }
public async Task <InvestimentosResposta> Get() { var resp = new InvestimentosResposta(); var lcis = new LciModel(); var fundos = new FundoModel(); var tes = new TesouroDiretoModel(); var dtLim = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 23, 59, 59); double minExpirate = (dtLim - DateTime.Now).TotalMinutes; var opcoesCache = new DistributedCacheEntryOptions(); opcoesCache.SetAbsoluteExpiration(TimeSpan.FromMinutes(minExpirate)); //lcis = await _lcis.Get(); //fundos = await _fundos.Get(); //tes = await _tds.Get(); var lcCache = this._distributedCache.GetString("lcis"); var fuCache = this._distributedCache.GetString("fundos"); var teCache = this._distributedCache.GetString("tes"); if (lcCache != null) { lcis = JsonSerializer.Deserialize <LciModel>(lcCache); } else { lcis = await _lcis.Get(); this._distributedCache.SetString("lcis", JsonSerializer.Serialize(lcis), opcoesCache); } if (fuCache != null) { fundos = JsonSerializer.Deserialize <FundoModel>(fuCache); } else { fundos = await _fundos.Get(); this._distributedCache.SetString("fundos", JsonSerializer.Serialize(fundos), opcoesCache); } if (teCache != null) { tes = JsonSerializer.Deserialize <TesouroDiretoModel>(teCache); } else { tes = await _tds.Get(); this._distributedCache.SetString("tes", JsonSerializer.Serialize(tes), opcoesCache); } foreach (var l in lcis.lcis) { resp.investimentos.Add(l.ToModel()); } foreach (var fu in fundos.fundos) { resp.investimentos.Add(fu.ToModel()); } foreach (var td in tes.tds) { resp.investimentos.Add(td.ToModel()); } return(resp); }
public static List <Investimento> ToModels(this FundoModel model) { return(model.fundos.Select(item => item.ToModel()).ToList()); }