/// <summary> /// Create a new transaction object. /// </summary> /// <param name="idTransaction">Initial value of the idTransaction property.</param> /// <param name="tStamp">Initial value of the tStamp property.</param> /// <param name="account">Initial value of the account property.</param> /// <param name="debit">Initial value of the debit property.</param> /// <param name="credit">Initial value of the credit property.</param> public static transaction Createtransaction(global::System.Int32 idTransaction, global::System.String tStamp, global::System.String account, global::System.Double debit, global::System.Double credit) { transaction transaction = new transaction(); transaction.idTransaction = idTransaction; transaction.tStamp = tStamp; transaction.account = account; transaction.debit = debit; transaction.credit = credit; return(transaction); }
public ActionResult Deposit(TransactionModel model) { if (ModelState.IsValid && model.credit > 0) { string dtStamp = DateTime.Now.ToString(); var dbATM = new ATMEntities(); var transaction = new transaction { tStamp = dtStamp, credit = model.credit, account = model.account, debit = 0 }; dbATM.transactions.AddObject(transaction); dbATM.SaveChanges(); TempData["successD"] = "Y"; } else { ModelState.AddModelError("", "The deposit value provided is incorrect."); } return View(model); }
public ActionResult Withdraw(TransactionModel model) { if (ModelState.IsValid && model.debit > 0) { string dtStamp = DateTime.Now.ToString(); var balance = getAccountBalance(model.account); if (balance <= model.debit) { TempData["successW"] = "N"; } else { var dbATM = new ATMEntities(); var transaction = new transaction { tStamp = dtStamp, debit = model.debit, account = model.account, credit = 0 }; dbATM.transactions.AddObject(transaction); dbATM.SaveChanges(); TempData["successW"] = "Y"; } return View(model); } else { ModelState.AddModelError("", "The withdrawal value provided is incorrect."); } return View(model); }
/// <summary> /// Deprecated Method for adding a new object to the transactions EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddTotransactions(transaction transaction) { base.AddObject("transactions", transaction); }
/// <summary> /// Create a new transaction object. /// </summary> /// <param name="idTransaction">Initial value of the idTransaction property.</param> /// <param name="tStamp">Initial value of the tStamp property.</param> /// <param name="account">Initial value of the account property.</param> /// <param name="debit">Initial value of the debit property.</param> /// <param name="credit">Initial value of the credit property.</param> public static transaction Createtransaction(global::System.Int32 idTransaction, global::System.String tStamp, global::System.String account, global::System.Double debit, global::System.Double credit) { transaction transaction = new transaction(); transaction.idTransaction = idTransaction; transaction.tStamp = tStamp; transaction.account = account; transaction.debit = debit; transaction.credit = credit; return transaction; }