public Transactions CashTransfer(CustomerBO cbo, decimal amount, int accNo) //used to transfer cash just like withdraw { //creates a transaction of transfer type and then decrease the balance from the Transactions ts = new Transactions { Type = "transfered", DT = DateTime.Now, UserID = cbo.UserID, Balance = amount }; MainDAL dal = new MainDAL(); //cbo's balance and increase in the balance of customer whose account number is dal.CreateTrasaction(ts); //accNo. List <CustomerBO> list = new List <CustomerBO>(); List <CustomerBO> newList = new List <CustomerBO>(); list = CustomerDecryption(); CustomerBO tempcbo = new CustomerBO(); foreach (CustomerBO u in list) { if (u.AccountNo == cbo.AccountNo) { u.Balance = u.Balance - amount; } if (u.AccountNo == accNo) { u.Balance = u.Balance + amount; } tempcbo = u; tempcbo = CustomerEncryption(tempcbo); newList.Add(tempcbo); } dal.RestoreCustomerAccounts(newList); return(ts); }
public Transactions DepositCash(CustomerBO cbo, decimal amount) //used to deposit a cash into a customer account { //firstly creates a transaction of deposit type and then add amount in the balance Transactions ts = new Transactions { Type = "deposited", DT = DateTime.Now, UserID = cbo.UserID, Balance = amount }; MainDAL dal = new MainDAL(); //of cbo who is current user. dal.CreateTrasaction(ts); List <CustomerBO> old = CustomerDecryption(); List <CustomerBO> newList = new List <CustomerBO>(); CustomerBO tempBo = new CustomerBO(); foreach (CustomerBO u in old) { if (u.AccountNo == cbo.AccountNo) { u.Balance = u.Balance + amount; } tempBo = u; tempBo = CustomerEncryption(tempBo); newList.Add(tempBo); } dal.RestoreCustomerAccounts(newList); return(ts); }
public Transactions WithdrawCash(CustomerBO cbo, decimal amount) //first it creates transaction of withdraw type { //and then get the decrypted customers in a list and decrement Transactions ts = new Transactions { Type = "withdrawn", DT = DateTime.Now, UserID = cbo.UserID, Balance = amount }; MainDAL dal = new MainDAL(); //amount from balance of that customer who is cbo. dal.CreateTrasaction(ts); List <CustomerBO> list = new List <CustomerBO>(); List <CustomerBO> newList = new List <CustomerBO>(); list = CustomerDecryption(); CustomerBO tempcbo = new CustomerBO(); foreach (CustomerBO u in list) { if (u.UserID == cbo.UserID) { u.Balance = u.Balance - amount; } tempcbo = u; tempcbo = CustomerEncryption(tempcbo); newList.Add(tempcbo); } dal.RestoreCustomerAccounts(newList); return(ts); }