public StoreForm(User currentUser,UserManager usermanager, ItemManager itemmanager) { _currentUser = currentUser; //Assigns the current user. InitializeComponent(); _itemManager = itemmanager; //Assigns the itemmanager. _userManager = usermanager; // Assings the usermanager. UpdateGUI(_currentUser); //Updates the GUI with user information. }
public User Login(string username, string password) { _user = _userList.Find(u => u.Username == username && u.Password == password); //Gets the user who is about to login. if(_user == null) { throw new ApplicationException("Login Failed"); } return _user; }
private void CreateUser(string userName, string passWord) { _user = new User(userName, passWord); // Creates a new user with the given username and password. _userList.Add(_user); // Adds the new user to the userlist. }
private void UpdateGUI(User cu) { lstBoxItems.Items.Clear(); //Clears the item listbox. lstBoxTrolly.Items.Clear(); // Clears the personal trolly listbox. if (lblUsername.Text == null || lblUsername.Text == "") { lblUsername.Text = cu.Username + "'s Trolly"; // Sets the name label to the current users username. } // Gets each item from the current users personal trolly and popultes the personal trolly listbox with the relevant items. // Sets the total cost label to the total cost of the personal trolly items. foreach (Item personalItem in _userManager.GetPersonalTrolly()) { lstBoxTrolly.Items.Add(personalItem); lblTotalCost.Text = _userManager.GetTotalCost().ToString(); } if (_itemManager.Filter == "All") { foreach (Item item in _itemManager.ItemList) { lstBoxItems.Items.Add(item); //Adds all the items from itemList to the item listbox. } } else { foreach (Item item in _itemManager.FilterList) { lstBoxItems.Items.Add(item); } } }