Beispiel #1
0
        public async Task <IActionResult> AddCredit(TransactionViewModel transaction)
        {
            User user = await _userProvider.GetUserByIdAsync(1);

            if (user.Amount >= transaction.Amount)
            {
                user.Amount -= transaction.Amount;
                await _userProvider.EditUserAsync(user);

                await _transactionProvider.CreateTransactionAsync(transaction);

                return(Ok());
            }
            else
            {
                return(StatusCode(403));
            }
        }