Exemple #1
0
        // GET: /<controller>/
        public IActionResult Index()
        {
            var model = new Models.CurrencyConverter.ConversionModel();
            var codes = GetAllCodes();

            model.ISO_Codes = GetSelectListItems(codes);

            return(View(model));
        }
Exemple #2
0
        public IActionResult Index(Models.CurrencyConverter.ConversionModel model)
        {
            var codes = GetAllCodes();

            model.ISO_Codes = GetSelectListItems(codes);

            var rates = GetExchangeRates(model.Base_Currency);

            var exchangeRate = rates.Rates.GetType().GetProperty(model.Exchange_Currency).GetValue(rates.Rates, null);

            var conversionAmount = model.Amount * (double)exchangeRate;


            ViewBag.result = string.Format("{0} {1} = {2} {3}", model.Amount, model.Base_Currency, conversionAmount, model.Exchange_Currency);


            return(View(model));
        }