Beispiel #1
0
        public string SendMoney(Transfers transfers)
        {
            Accounts senderObject   = accountsDAO.GetAccountBalance(transfers.account_from);
            Accounts receiverObject = accountsDAO.GetAccountBalance(transfers.account_to);

            if (senderObject.Balance >= transfers.Amount && transfers.account_to != transfers.account_from)
            {
                receiverObject.Balance += transfers.Amount;
                senderObject.Balance   -= transfers.Amount;

                transferDAO.UpdateBalance(transfers.account_from, senderObject.Balance);
                transferDAO.UpdateBalance(transfers.account_to, receiverObject.Balance);


                transferDAO.LogTransfers(TransferType.Send, TransferStatus.Approved, senderObject.AccountId, receiverObject.AccountId, transfers.Amount);

                return("Transfer was successful");               //Make a more elegant response if time allows
            }
            else if (senderObject.Balance < transfers.Amount)
            {
                return("Your balance is insufficient to send the desired amount of money"); //CHANGE LATER IF NEEDED
            }
            else if (transfers.account_to == transfers.account_from)                        //could take out
            {
                return("You cannot send money to yourself.");
            }
            else
            {
                return("Unsuccessful transfer.");
            }
        }
Beispiel #2
0
        public ActionResult <Accounts> GetAccountBalance(int id)         //change to get MY account balance
        {
            Accounts account = accntDAO.GetAccountBalance(id);

            if (account == null)
            {
                return(NotFound());
            }
            else
            {
                return(account);
            }
        }