private void AdminSetup() { var acc0 = new AdminAccount(0, "admin-pete-w", "password", "Pete Wilkinson", false); AccountList accList = new AccountList(true); accList.AddAdminAccount(acc0); accList.SaveAdminData(); }
/// <summary> /// Constructor for the scanner class that takes two parameters /// </summary> /// <param name="location"></param> /// <param name="entry"></param> public Scanner(Station location, bool entry) { _location = location; _entry = entry; _accounts = new AccountList(Persister.ReadFromBinaryFile <List <CustomerAccount> >(@"Accounts.txt")); _aBarrier = new Barrier(); _routeList = new RouteList(); }
/// <summary> /// constructor for the scanner class that takes four parameters /// </summary> /// <param name="location"></param> /// <param name="entry"></param> /// <param name="a"></param> /// <param name="b"></param> public Scanner(Station location, bool entry, AccountList a, RouteList b) { _location = location; _entry = entry; _accounts = a; _aBarrier = new Barrier(); _routeList = new RouteList(); _routeList = b; }
public AdminAccount(int id) { var temp = new AccountList(true).GetAdminAccountById(id); _routes = temp._routes; _loginStatus = temp._loginStatus; _accountId = temp._accountId; _fullName = temp._fullName; _password = temp._password; _username = temp._username; }
/// <summary> /// This function logs out a user from the system. /// </summary> /// <param name="accountId">The user ID to log out.</param> /// <returns>returns -1 to show the user has been logged out. </returns> public int LogoutAdmin(int accountId) { var accs = Persister.ReadFromBinaryFile <List <AdminAccount> >(@"AdminAccounts.txt"); foreach (var account in accs) { if (account._accountId == accountId) { account._loginStatus = false; var temp = new AccountList(accs); temp.SaveAdminData(); return(-1); } } return(-1); }
/// <summary> /// Constructor used for updating account in the file /// </summary> /// <param name="id">Account ID of the account being updated</param> public CustomerAccount(int id) { var temp = new AccountList(false).GetAccountById(id); _cardId = temp._cardId; _balance = temp._balance; _savedPaymentMethods = temp._savedPaymentMethods; _JourneyList = temp._JourneyList; _paymentList = temp._paymentList; _transactionList = temp._transactionList; _endStation = temp._endStation; _startStation = temp._startStation; _loginStatus = temp._loginStatus; _accountId = temp._accountId; _fullName = temp._fullName; _password = temp._password; _username = temp._username; }
private void CustomerSetup() { Random rand = new Random(); var acc0 = new CustomerAccount(0, 0, 0, "GUEST", "djkffsdf", "GUEST ACCOUNT", true); var acc1 = new CustomerAccount(rand.Next(1000000, 9999999), 0, 1, "Bob", "password", "Bob Hitler", false); var acc2 = new CustomerAccount(rand.Next(1000000, 9999999), 0, 2, "Rudy", "password", "Rudy Smeg", false); var acc3 = new CustomerAccount(rand.Next(1000000, 9999999), 0, 3, "Judy", "password", "Judy Spagghettio", false); var acc4 = new CustomerAccount(rand.Next(1000000, 9999999), 0, 4, "John", "password", "John Smith", false); var acc5 = new CustomerAccount(rand.Next(1000000, 9999999), 0, 5, "Clarence", "password", "Clarence Angel", false); AccountList accList = new AccountList(false); accList.AddCustomerAccount(acc0); accList.AddCustomerAccount(acc1); accList.AddCustomerAccount(acc2); accList.AddCustomerAccount(acc3); accList.AddCustomerAccount(acc4); accList.AddCustomerAccount(acc5); accList.SaveCustomerData(); }
/// <summary> /// This function takes the username and password entered by the user. /// It then calls the function to read the Accounts file; this then verifies the entered details /// against the stored details. If both match, it returns the accountId. /// </summary> /// <param name="username">A string containing the username the user entered when attempting to log in.</param> /// <param name="password">A string containing the password the user entered when attempting to log in.</param> /// <returns>If successful, the accountId, else -1 to signal a failure.</returns> public int VerifyLogin(string username, string password) { if (username.StartsWith("admin")) { var accs = Persister.ReadFromBinaryFile <List <AdminAccount> >(@"AdminAccounts.txt"); foreach (var account in accs) { if (account._username == username && account._password == password) { if (account._loginStatus) { return(-2); } account._loginStatus = true; var temp = new AccountList(accs); temp.SaveAdminData(); return(account._accountId); } } return(-1); } else { var accs = Persister.ReadFromBinaryFile <List <CustomerAccount> >(@"Accounts.txt"); foreach (var account in accs) { if (account._username == username && account._password == password) { if (account._loginStatus) { return(-2); } account._loginStatus = true; var temp = new AccountList(accs); temp.SaveCustomerData(); return(account._accountId); } } return(-1); } }