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()); }
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; } } }
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")); }