public bool CheckUserCredentials(User userCredentials) { foreach (User user in m_users) { if (user.Name == userCredentials.Name) { if (user.Password == userCredentials.Password) { return true; } } } return false; }
public bool AddUser(User a_user) { if (IsUsernameUnique(a_user.Name) && a_user.HasCorrectDetails) { //subscribe to user events a_user.AddSubscriber(this); //add it to array m_users.Add(a_user); //notify subscribers this.NotifySubscribersChangeMade(a_user); return true; } return false; }
private void NotifySubscribersChangeMade(User a_user) { if (m_observers != null) { foreach (UserObserver o in m_observers) { o.UserChangeMade(a_user); } } }
private bool DeleteUser(User a_user) { bool success = this.Users.Remove(a_user); if (success) { //un-subscribe to user events a_user.RemoveSubscriber(this); this.NotifySubscribersChangeMade(a_user); } return success; }