/// <summary> /// Takes a user and an amount and returns the transaction /// </summary> /// <param name="user"></param> /// <param name="amount"></param> /// <returns></returns> public InsertCashTransaction AddCreditsToAccount(User user, int amount) { Transaction transaction = new InsertCashTransaction(_logFile.LinesInFile + 1, user, amount); ExecuteTransaction(transaction); return(transaction as InsertCashTransaction); }
// Inserting cash to a users account public InsertCashTransaction AddCreditsToAccount(User user, decimal amount) { InsertCashTransaction insertCashTransaction = new InsertCashTransaction(user, DateTime.Now, amount); ExecuteTransaction(insertCashTransaction); _writingfiles.WritingUsersFile(insertCashTransaction); user.NumberOfTransactions++; return(insertCashTransaction); }
public int AddCreditsToAccount(User user, float amount) { InsertCashTransaction insertCashTransaction = new InsertCashTransaction(user, amount); TrackTransaction(insertCashTransaction); Logger.WriteMessage(insertCashTransaction.ToString()); return(0); }
public InsertCashTransaction AddCreditsToAccount(User user, int amount) { InsertCashTransaction insCashTrans = new InsertCashTransaction(user, amount); _transactionList.Add(insCashTrans); LogTransaction(insCashTrans.ToString()); return(insCashTrans); }
public StregsystemController(IStregsystemUI ui) { UI = (StregsystemCLI)ui; _adminCommands = new Dictionary <string, Action <dynamic, dynamic> > { { "?", (x, y) => UI.DisplayHelp() }, { ":q", (x, y) => UI.Close() }, { ":quit", (x, y) => UI.Close() }, { ":activate", (x, y) => { Product.Find(int.Parse(x)).Activate(); UI.DisplayActivation(int.Parse(x), true); } }, { ":deactivate", (x, y) => { Product.Find(int.Parse(x)).Deactivate(); UI.DisplayActivation(int.Parse(x), false); } }, { ":crediton", (x, y) => { Product.Find(x).CanBeBoughtOnCredit = true; UI.DisplayCreditChange(x, false); } }, { ":creditoff", (x, y) => { Product.Find(x).CanBeBoughtOnCredit = false; UI.DisplayCreditChange(x, false); } }, { ":addcredits", (x, y) => { User u = User.FindBy("Username", x); var transaction = new InsertCashTransaction(u, decimal.Parse(y)); transaction.Execute(); UI.DisplayAddedCreditsToUser(User.FindBy("Username", x), decimal.Parse(y)); } } }; }
private void InsertCashTransaction(string username, int amount) { User user = _stregsystem.GetUserByUsername(username); if (user != null) { if (amount > 0) { InsertCashTransaction iCT = _stregsystem.AddCreditsToAccount(user, amount); _ui.DisplayTransaction(iCT); } else { _ui.DisplayGeneralError("Cannot insert negative cash."); } } }
public InsertCashTransaction AddCreditsToAccount(User user, decimal amount, List <User> UserList) { InsertCashTransaction Transaction = new InsertCashTransaction(user, DateTime.Now, amount, UserList); return(Transaction); }