Esempio n. 1
0
 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);
     }
 }
Esempio n. 2
0
 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();
     }
 }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        private static bool ExisteListagem(MoedaListagemDTO moedaInstance)
        {
            bool ExisteListagem = moedaInstance.ListagemMoeda.Count > 0;

            return(ExisteListagem);
        }