Example #1
0
        public async Task SeedDefaultDisplayedCurrenciesSettings()
        {
            ExchangeRatesTable exchangeRatesTable = await App.NbpClient.GetCurrentTable();

            List<SettingDisplayedCurrencyEntity> currencySettings = exchangeRatesTable.ExchangeRates.Select(
                rate => new SettingDisplayedCurrencyEntity(rate.CurrencyCode, rate.CurrencyName, true)).ToList();

            db.BeginTransaction();
            db.DeleteAll<SettingDisplayedCurrencyEntity>();
            db.InsertAll(currencySettings, runInTransaction: false);
            db.Commit();
        }
Example #2
0
        public async Task <ExchangeRatesTable> GetCurrentTable()
        {
            HttpResponseMessage response = await httpClient.GetAsync("exchangerates/tables/c/");

            ExchangeRatesTable currentTable = null;

            if (response.IsSuccessStatusCode)
            {
                string body = await response.Content.ReadAsStringAsync();

                currentTable = JsonConvert.DeserializeObject <List <ExchangeRatesTable> >(body)[0];
            }

            return(currentTable);
        }
Example #3
0
        public DijkstraPathFinder(ExchangeRatesTable table)
        {
            // We computed inverted exchange rates so that the graph will contains
            // all possible nodes connections.

            // For example we can't find a path between EUR -> JPY with these exchange rates :
            // EUR -> CHF
            // AUD -> CHF
            // AUD -> JPY
            // By inverting AUD -> CHF we provided the full path to EUR -> JPY.
            var exchangeRates = table.ExchangeRates
                                .Concat(WithInvertedExchangeRates(table.ExchangeRates))
                                .ToList();

            foreach (var exchangeRate in exchangeRates)
            {
                this.AddNodes(exchangeRate);
            }
        }
 public Content(Conversion conversion, ExchangeRatesTable exchangeRates)
 {
     this.Conversion    = conversion;
     this.ExchangeRates = exchangeRates;
 }