public static Teller CreateTeller(string name, string password, List<TellerPermissions> permissions) { Teller teller = new Teller(tellers.Count, name, password, permissions); tellers.Add(teller.ID, teller); Log("Teller (" + teller.Name + ") with ID " + teller.ID + " created"); return teller; }
/// <summary> /// Searches the sessions to see if there is one between the two /// </summary> /// <param name="teller">The teller</param> /// <param name="account">The account</param> /// <returns>Returns the session if found. If not, returns null</returns> public static Session FindSession(Teller teller) { foreach (Session session in sessions) { if (session.Teller == teller) return session; } return null; }
public Session(Teller teller, Account account) { this.teller = teller; this.account = account; }
/// <summary> /// Creates a new account without using a session /// </summary> /// <param name="teller">Teller</param> /// <param name="account">Account</param> /// <returns></returns> public static BankResult CreateNewAccount(Teller teller, Account account) { if (!tellers.ContainsKey(teller.ID)) return BankResult.TellerInvalid; if (accounts.ContainsValue(account)) return BankResult.AccountExists; account.Log(Encrypt("Account created by " + teller.Name + " (" + teller.ID + ")")); teller.Log(Encrypt("Created account for ID " + account.ID)); Log("Teller ID " + teller.ID + " created an account for account ID " + account.ID); accounts.Add(account.ID, account); return BankResult.AccountCreated; }
/// <summary> /// Creates a session between a teller and an account /// </summary> /// <param name="teller">Teller</param> /// <param name="account">Account</param> public static void CreateSession(Teller teller, int id) { CreateSession(teller, FindAccount(id)); }
/// <summary> /// Creates a session between a teller and an account /// </summary> /// <param name="teller">Teller</param> /// <param name="account">Account</param> public static void CreateSession(Teller teller, Account account) { Session session = new Session(teller, account); sessions.Add(session); }