public ActionResult ApproveTransaction(int id)
        {
            inject();
            var check = _context.ForwardTransfers.Find(id);

            if (check == null)
            {
                return(RedirectToAction("Transactions"));
            }

            var accountService = new Services.Account();

            var balance    = Convert.ToDecimal(accountService.GetBalance(check.AccountID));
            var newBalance = Convert.ToDecimal(balance - check.Amount);

            accountService.UpdateAccountBalance(check.AccountID, newBalance);

            check.Status = Services.TransactionStatus.SUCCESSFUL.ToString();
            _context.Entry(check);
            _context.SaveChanges();
            return(RedirectToAction("Transactions"));
        }
        public ActionResult Transfer(TransferDto m)
        {
            inject();
            string userId = User.Identity.GetUserId();

            accountNumber = new Services.Account().getAccountNumber(userId);

            var codes = _context.TransactionCodes.Where(a => a.AccountNo == accountNumber).FirstOrDefault();
            //valid codes

            var accountService = new Services.Account();
            var checkDes       = accountService.FindAccount(m.destinationAccountNo);

            if (checkDes == true)
            {
                //save transaction
                //get balance
                var balance = Convert.ToDecimal(accountService.GetBalance(accountNumber));
                if (balance >= m.amount)
                {
                    var newBalance = balance - m.amount;
                    accountService.UpdateAccountBalance(accountNumber, newBalance);
                    _context.ForwardTransfers.Add(new ForwardTransfer
                    {
                        AccountID           = m.accountNo,
                        Amount              = m.amount,
                        BeneficaryAddress   = m.address,
                        BeneficaryBank      = m.bBankName,
                        BeneficaryName      = m.bName,
                        BeneficarySwiftCode = m.swiftCode,
                        IBAN = m.iban,
                        DestinationAccountNo = m.destinationAccountNo,
                        Purpose = m.purpose,
                        Status  = Services.TransactionStatus.SUCCESSFUL.ToString(),
                        Date    = DateTime.UtcNow
                    });
                    _context.SaveChanges();
                    var destinationAccountBalance         = Convert.ToDecimal(accountService.GetBalance(m.destinationAccountNo));
                    var destnationNewBalance              = destinationAccountBalance + m.amount;
                    var updateDestinatationAccountBalance = accountService.UpdateAccountBalance(m.destinationAccountNo, destnationNewBalance);
                    return(Json(new { status = 200, message = "Transaction Successful" }));
                }
                else
                {
                    //Insufficent Fund
                    return(Json(new { status = 0, message = "Insufficent Fund in account" }));
                }
            }
            else if (codes == null)
            {
                return(Json(new { status = 0, message = "Something went wrong please contact service provider " }));
            }
            else if (codes.COT == m.cot && codes.IMF == m.imf && codes.TAX == m.tax)
            {
                //check if destination account

                _context.ForwardTransfers.Add(new ForwardTransfer
                {
                    AccountID           = m.accountNo,
                    Amount              = m.amount,
                    BeneficaryAddress   = m.address,
                    BeneficaryBank      = m.bBankName,
                    BeneficaryName      = m.bName,
                    BeneficarySwiftCode = m.swiftCode,
                    IBAN = m.iban,
                    DestinationAccountNo = m.destinationAccountNo,
                    Purpose = m.purpose,
                    Status  = Services.TransactionStatus.PENDING.ToString(),
                    Date    = DateTime.UtcNow
                });
                _context.SaveChanges();
                //no account in system
                return(Json(new { status = 200, message = "Request has been sent, and its awaiting approval" }));
            }
            else
            {
                return(Json(new { status = 0, message = "Transaction Failed at this moment, Hope you entered the right infomations" }));
            }
        }