private static void AdicionaMoedaNaListagem(MoedaListagemDTO MoedaListagemInstance, MoedaDTO MoedaDTOInstance) { foreach (KeyValuePair <string, string> cotacao in MoedaDTOInstance.DictionaryMoedas) { Moeda Moeda = MoedaDTO.Create(cotacao.Key, cotacao.Value); MoedaListagemInstance.ListagemMoeda.Add(Moeda); } }
private static void AtualizaValoresDeCotacao(MoedaListagemDTO MoedaListagemInstance, MoedaDTO MoedaDTOInstance) { foreach (KeyValuePair <string, double> cotacao in MoedaDTOInstance.DictionaryCotacoes) { MoedaListagemInstance.ListagemMoeda .Where(moeda => moeda.Sigla == cotacao.Key.Substring(3)) .Select(moeda => { moeda.Valor = cotacao.Value; return(moeda); }) .ToList(); } }
public static async Task <List <Moeda> > ListagemMoedas() { MoedaListagemDTO MoedaListagemInstance = MoedaListagemDTO.GetInstance(); MoedaDTO MoedaDTOInstance = MoedaDTO.GetInstance(); if (ExisteListagem(MoedaListagemInstance)) { return(MoedaListagemInstance.ListagemMoeda); } MoedaDTOInstance = await RequestAPILayer(MoedaDTOInstance, "list"); MoedaDTOInstance = await RequestAPILayer(MoedaDTOInstance, "live"); AdicionaMoedaNaListagem(MoedaListagemInstance, MoedaDTOInstance); AtualizaValoresDeCotacao(MoedaListagemInstance, MoedaDTOInstance); return(MoedaListagemInstance.ListagemMoeda); }
private static bool ExisteListagem(MoedaListagemDTO moedaInstance) { bool ExisteListagem = moedaInstance.ListagemMoeda.Count > 0; return(ExisteListagem); }