public List <TransactionHistoryModel> GetTransactionHistory(long checkingAccountNum) { List <TransactionHistoryModel> THList = null; try { CacheAbstraction cabs = new CacheAbstraction(); THList = cabs.Retrieve <List <TransactionHistoryModel> >("TRHISTORY" + ":" + checkingAccountNum); if (THList != null) { return(THList); } string sql = "select th.*, trt.TransactionTypeName from TransactionHistories th " + "inner join TransactionTypes trt on th.TransactionTypeId=trt.TransactionTypeId " + "where CheckingAccountNumber=@CheckingAccountNumber"; List <DbParameter> ParamList = new List <DbParameter>(); SqlParameter p1 = new SqlParameter("@CheckingAccountNumber", SqlDbType.BigInt); p1.Value = checkingAccountNum; ParamList.Add(p1); DataTable dt = _idac.GetManyRowsCols(sql, ParamList); //if (dt.Rows[0]["Amount"].ToString() != null) //{ // string amt = dt.Rows[0]["Amount"].ToString(); //} THList = DBList.ToList <TransactionHistoryModel>(dt); cabs.Insert("TRHISTORY" + ":" + checkingAccountNum, THList); } catch (Exception) { throw; } return(THList); }
public bool payBill(long checkingAccountNum, int billId, decimal?amount) { bool res = false; string CONNSTR = ConfigurationManager.ConnectionStrings["MYBANK"].ConnectionString; SqlConnection conn = new SqlConnection(CONNSTR); SqlTransaction sqtr = null; try { conn.Open(); sqtr = conn.BeginTransaction(); int rows = UpdateCheckingBalanceTR(checkingAccountNum, -1 * (decimal)amount, conn, sqtr, true); if (rows == 0) { throw new Exception("Problem in transferring from Checking Account.."); } object obj = GetCheckingBalanceTR(checkingAccountNum, conn, sqtr, true); if (obj != null) { if (decimal.Parse(obj.ToString()) < 0) // exception causes transaction to be rolled back { throw new Exception("Insufficient funds in Checking Account - rolling back transaction"); } int result = 0; result = AddToTransactionHistoryTR(checkingAccountNum, billId, (decimal)amount, 102, 0, conn, sqtr, true); //102 for tanstype for billpay if (result > 0) { result = UpdateBillsPaymentStatus(billId, conn, sqtr, true); sqtr.Commit(); res = true; // clear the cache CacheAbstraction cabs = new CacheAbstraction(); cabs.Remove("TRHISTORY"); } else { throw new Exception("Error in Updating the transaction history"); } } else { throw new Exception("Error in Updating the checking Balance"); } } catch (Exception) { throw; } finally { conn.Close(); } return(res); }
public bool TransferSavingToChecking(long checkingAccountNum, long savingAccountNum, decimal amount, decimal transactionFee) { // transfer saving to checking has to be done as a transaction // transactions are assocated with a connection bool ret = false; string CONNSTR = ConfigurationManager.ConnectionStrings["MYBANK"].ConnectionString; SqlConnection conn = new SqlConnection(CONNSTR); SqlTransaction sqtr = null; try { conn.Open(); sqtr = conn.BeginTransaction(); int rows = UpdateSavingBalanceTR(savingAccountNum, -1 * amount, conn, sqtr, true); if (rows == 0) { throw new Exception("Problem in transferring from Checking Account.."); } object obj = GetSavingBalanceTR(savingAccountNum, conn, sqtr, true); if (obj != null) { if (decimal.Parse(obj.ToString()) < 0) // exception causes transaction to be rolled back { throw new Exception("Insufficient funds in Checking Account - rolling back transaction"); } } rows = UpdateCheckingBalanceTR(checkingAccountNum, amount, conn, sqtr, true); if (rows == 0) { throw new Exception("Problem in transferring to Saving Account.."); } string transtype = "SavingToChecking"; rows = AddToTransactionHistoryTR(checkingAccountNum, savingAccountNum, amount, transtype, 101, transactionFee, conn, sqtr, true); if (rows == 0) { throw new Exception("Problem in transferring to Saving Account.."); } else { sqtr.Commit(); ret = true; // clear the cache CacheAbstraction cabs = new CacheAbstraction(); cabs.Remove("TRHISTORY"); } } catch (Exception) { throw; } finally { conn.Close(); } return(ret); }
public ActionResult Login(LoginModel lm) { IBusinessAuthentication iba = GenericFactory <Business, IBusinessAuthentication> .GetInstance(); IBusinessBanking ibank = GenericFactory <Business, IBusinessBanking> .GetInstance(); IBusinessLoan iloan = GenericFactory <Business, IBusinessLoan> .GetInstance(); if (ModelState.IsValid) { // check if valid user bool ret = iba.CheckIfValidUser(lm.Username, lm.Password); if (ret == true) { string roles = iba.GetRolesForUser(lm.Username); // send the pipedelimited roles as an authentication cookie back to the browser FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(1, lm.Username, DateTime.Now, DateTime.Now.AddMinutes(15), false, roles); string encryptedTicket = FormsAuthentication.Encrypt(authTicket); HttpCookie ck = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket); Response.Cookies.Add(ck); // ----obtaing checking account number and saving account number for user long checkingAccountNum = ibank.GetCheckingAccountNumForUser(lm.Username); long savingAccountNumber = ibank.GetSavingAccountNumForUser(lm.Username); UserInfo ui = new UserInfo(); ui.CheckingAcccountNumber = checkingAccountNum; ui.SavingAccountNumber = savingAccountNumber; ui.Username = lm.Username; //HttpCookie ckuser = new HttpCookie("UserInfo"); //ckuser["USERDATA"] = ui.LosSerialize(); //Response.Cookies.Add(ckuser); CookieFacade.USERINFO = ui; CacheAbstraction cabs = new CacheAbstraction(); cabs.Remove("TRHISTORY" + ":" + checkingAccountNum); //---------------------------------------------------- string redirectURL = FormsAuthentication.GetRedirectUrl(lm.Username, false); if (redirectURL == "/default.aspx") { redirectURL = "~/home/index"; } //Response.Redirect(redirectURL); // causes antiforgery token exception return(Redirect(redirectURL)); } ViewBag.Message = "Invalid login.."; } return(View(lm)); }
public bool ApplyLoan(long checkingAccountNum, long savingAccountNum, decimal amount, string username, decimal transactionFee) { // apply loan by a user has to be done as a transaction // transactions are assocated with a connection bool ret = false; string CONNSTR = ConfigurationManager.ConnectionStrings["MYBANK"].ConnectionString; SqlConnection conn = new SqlConnection(CONNSTR); SqlTransaction sqtr = null; try { conn.Open(); sqtr = conn.BeginTransaction(); string roles = GetRolesForUser(username); int rows = UpdateStatusTR(checkingAccountNum, roles, username, conn, sqtr, true); if (rows == 0) { throw new Exception("Problem in appyling the loan.."); } string TransType = "Apply Loan"; rows = AddToTransactionHistoryTR(checkingAccountNum, savingAccountNum, amount, TransType, 103, transactionFee, conn, sqtr, true); if (rows == 0) { throw new Exception("Problem in appyling the loan.."); } else { sqtr.Commit(); ret = true; // clear the cache CacheAbstraction cabs = new CacheAbstraction(); cabs.Remove("TRHISTORY"); } } catch (Exception) { throw; } finally { conn.Close(); } return(ret); }
public bool LoanApproval(long checkingAccountNum, long savingAccountNum, decimal amount, List <string> Username, decimal transactionFee) { // transfer checking to saving has to be done as a transaction // transactions are assocated with a connection bool ret = false; string CONNSTR = ConfigurationManager.ConnectionStrings["MYBANK"].ConnectionString; SqlConnection conn = new SqlConnection(CONNSTR); SqlTransaction sqtr = null; try { conn.Open(); sqtr = conn.BeginTransaction(); int rows = UpdateLoanApprovalStatusTR(checkingAccountNum, Username, conn, sqtr, true); if (rows == 0) { throw new Exception("Problem in updating loan status.."); } string TransType = "Loan Approval"; rows = AddToTransactionHistoryTR(checkingAccountNum, savingAccountNum, amount, TransType, 100, transactionFee, conn, sqtr, true); if (rows == 0) { throw new Exception("Problem in updating to Transaction history for the loan status.."); } else { sqtr.Commit(); ret = true; // clear the cache CacheAbstraction cabs = new CacheAbstraction(); cabs.Remove("TRHISTORY"); } } catch (Exception) { throw; } finally { conn.Close(); } return(ret); }
// public Repository(IDataAccess ida, CacheAbstraction webc) public Repository(DataAbstraction dac, CacheAbstraction webc) { //_idataAccess = ida; _dac = dac; webCache = webc; }
public Repository(IDataAccess ida, CacheAbstraction webc) { _idataAccess = ida; webCache = webc; }
public RepositorySql() { idataAccess = GenericFactory <DataAccessSql, IDataAccess> .CreateInstance(); cache = new CacheAbstraction(); }
public RepositoryMySql(IDataAccess idac, CacheAbstraction webc) { _idataAccess = idac; webCache = webc; }
public TestCacheModel(CacheAbstraction cabs) { _cabs = cabs; }