Exemplo n.º 1
0
 public ActionResult TransferFunds(FundTransferViewModel model)
 {
     long customerID = (Session["User"] as UserRole).customerID;
     BankerDAL objBDAL = new BankerDAL();
     CustomerDAL objCDAL = new CustomerDAL();
     ViewBag.savingsAccountList = objCDAL.GetAllSavingsAccountByCustomerID(customerID);
     ViewBag.payeeAccounts = objCDAL.GetAllPayeeAccountByCustomerID(customerID);
     string message="";
     if (model.Amount <= 0)
     {
         //ModelState.AddModelError("", "Source and Dest cant be same");
         message =  "Amount must be positive";
         @ViewBag.message = message;
         return View(model);
     }
     if (model.FromAccount == model.ToAccount)
     {
         //ModelState.AddModelError("", "Source and Dest cant be same");
         message =  "Source and Destination account can't be same";
         @ViewBag.message = message;
         return View(model);
     }
     if (model.Amount > objBDAL.GetAccountBalance(model.FromAccount))
     {
         message =  "Insufficient funds. Please check balance";
         @ViewBag.message = message;
         return View(model);
     }
     if (objCDAL.ValidateTransactionPassword(customerID, model.TransactionPassword) == false)
     {
         message =  "Password is not valid";
         @ViewBag.message = message;
         return View(model);
     }
     if (objBDAL.GetAccountType(model.ToAccount) == 'L')
     {
         if (model.Amount > objBDAL.GetAccountBalance(model.ToAccount))
         {
             message =  "Invalid transaction";
             @ViewBag.message = message;
             return View(model);
         }
     }
     objCDAL.DoFundTransfer(model);
     message =  "Transaction Successful";
     @ViewBag.message = message;
     return View(model);
 }
Exemplo n.º 2
0
        public string SetBalance(int accountNumber, decimal amount, char accountType, char CreditOrDebit, string remarks)
        {
            BankerDAL objBankerDAL = new BankerDAL();
            if (accountType == 'S')
            {
                if (CreditOrDebit == 'C')//credit
                {
                    objBankerDAL.CreditSavingsAccountByBanker(accountNumber,amount,remarks);
                    return "Credit Successful";
                }
                else//debit
                {
                    if (amount <= objBankerDAL.GetAccountBalance(accountNumber))
                    {
                        objBankerDAL.DebitSavingsAccountByBanker(accountNumber, amount, remarks);
                        return "Debit successful";
                    }
                    else
                    {
                        return "Amount exceeds available balance";
                    }
                }
            }
            else
            {

                decimal loanBalance = objBankerDAL.GetAccountBalance(accountNumber);
                if (amount == loanBalance)
                {
                    objBankerDAL.CreditLoanAccountByBanker(accountNumber, amount, remarks);
                    objBankerDAL.CloseLoanAccount(accountNumber);
                    return "Credit Successful and Closed account";
                }
                else if (amount > loanBalance)
                {
                    return "Amount exceeds available balance";
                }
                else
                {
                    objBankerDAL.CreditLoanAccountByBanker(accountNumber, amount, remarks);
                    return "Credit Successful";
                }
            }
        }