public async Task <IActionResult> OnPostAsync(int value) { var cardNum = HttpContext.User.Claims.First().Value; //_transactionService.AddTransaction(cardNum, value, DateTime.Now, TransactionType.Deposit); var success = await _depositService.DepositAsync(cardNum, value); if (success) { Message = "Amount is deposit to your account"; Balance = _cardService.GetCardBalance(HttpContext.User.Claims.First().Value); return(Page()); } Message = "Amount could not deposit to your account"; return(Page()); }
public void AddTransaction(string cardNumber, decimal amount, DateTime date, TransactionType type) { var card = _unitOfWork.CardRepository.GetByCardNumber(cardNumber); var balance = card.Balance; if (amount != 0) { if (type == TransactionType.Deposit) { _withdrawService.WithdrawAsync(cardNumber, amount); //newBalance = balance + amount; } else { _depositService.DepositAsync(cardNumber, amount); //newBalance = balance - amount; } } // no transaction after 10.Or closed for service }