コード例 #1
0
        public async Task <IActionResult> Index()
        {
            var deserializedEUR = new Root();
            var deserializedUSD = new Root();

            deserializedEUR = await EService.GetExchange("eur");

            deserializedUSD = await EService.GetExchange("usd");

            var model = new ExchangeModel
            {
                effectiveDateUSD  = deserializedUSD.rates[0].effectiveDate,
                midUSD            = deserializedUSD.rates[0].mid,
                effectiveDateUSD1 = deserializedUSD.rates[1].effectiveDate,
                midUSD1           = deserializedUSD.rates[1].mid,
                changeUSD         = EService.GetChange(deserializedUSD.rates[0].mid, deserializedUSD.rates[1].mid),

                effectiveDateEUR  = deserializedUSD.rates[0].effectiveDate,
                midEUR            = deserializedEUR.rates[0].mid,
                effectiveDateEUR1 = deserializedUSD.rates[1].effectiveDate,
                midEUR1           = deserializedEUR.rates[1].mid,
                changeEUR         = EService.GetChange(deserializedEUR.rates[0].mid, deserializedEUR.rates[1].mid),
            };

            return(View(model));
        }
コード例 #2
0
        public void TestAverage()
        {
            List <Rate> ratesList = new List <Rate>();

            ratesList.Add(new Rate()
            {
                no = "152/A/NBP/2020", effectiveDate = "2020-08-06", mid = 4.4101
            });
            ratesList.Add(new Rate()
            {
                no = "153/A/NBP/2020", effectiveDate = "2020-08-07", mid = 4.4139
            });
            var PLN = new Root {
                table = "A", currency = "euro", code = "EUR", rates = ratesList
            };

            double changeUSD = EService.GetChange(PLN.rates[0].mid, PLN.rates[1].mid);

            Assert.Equal(0.086, changeUSD);
        }