public async Task <IActionResult> Create([Bind("CurrencyId,Name,Quantity")] Currency currency)
        {
            if (ModelState.IsValid)
            {
                currency.Quantity = 0;
                _context.Add(currency);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(currency));
        }
        public async Task <Transaction> CurrencyPurchase(Purchase purchase)
        {
            string[] exchange = await GetExchange(purchase.Currency);

            var user        = _context.Users.Find(purchase.UserId);
            var transaction = new Transaction()
            {
                User = user, Amount = purchase.Amount, Currency = purchase.Currency
            };

            transaction.Result = purchase.Amount * Double.Parse(exchange[1]);
            _context.Add(transaction);
            _context.SaveChanges();
            return(transaction);
        }
Beispiel #3
0
 public bool CreateOrEditTransactions(Transaction transaction)
 {
     transactions.Add(transaction);
     return(true);
 }