示例#1
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            SingleCurrencyExchange = await _context.SingleCurrencyExchange.FirstOrDefaultAsync(m => m.ID == id);

            if (SingleCurrencyExchange == null)
            {
                return(NotFound());
            }
            return(Page());
        }
示例#2
0
        public void exchangeCurrency(string nameCurrency, int amountToExchange)
        {
            decimal rate = 0;

            foreach (var x in data.Rates)
            {
                if (x.Key == nameCurrency)
                {
                    rate           = x.Value;
                    singleCurrency = new SingleCurrencyExchange(data.timeStamp, nameCurrency, Decimal.ToDouble(rate), amountToExchange);
                    dataBase.Add(singleCurrency);
                    dataBase.SaveChanges();
                    break;
                }
            }
        }
示例#3
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            SingleCurrencyExchange = await _context.SingleCurrencyExchange.FindAsync(id);

            if (SingleCurrencyExchange != null)
            {
                _context.SingleCurrencyExchange.Remove(SingleCurrencyExchange);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }