/** * Retrieve all users */ public Dictionary <int, User> getAllUser() { // Get all users from the identity map Dictionary <int, User> users = UserIdentityMap.getInstance().findAll(); // Get all users in the database Dictionary <int, Object[]> result = tdgUser.getAll(); // If it's empty, simply return those from the identity map if (result == null) { return(users); } // Loop through each of the result: foreach (KeyValuePair <int, Object[]> record in result) { // The user is not in the identity map. Create an instance, add it to identity map and to the return variable if (!users.ContainsKey(record.Key)) { User user = UserCatalog.getInstance().makeNewUser((int)record.Key, (String)record.Value[1], (String)record.Value[2], (String)record.Value[3]); UserIdentityMap.getInstance().addTo(user); users.Add(user.userID, user); } } return(users); }
/** * Set user attributes */ public void setUser(int userID, string name) { User user = UserCatalog.getInstance().modifyUser(userID, name); // We've modified something in the object so we Register the instance as Dirty in the UoW. UnitOfWork.getInstance().registerDirty(user); }
/** * Initialize the list of users, used for instantiating console * */ public void initializeDirectory() { // Get all users in the database Dictionary <int, Object[]> result = tdgUser.getAll(); //Loop through each of the result: foreach (KeyValuePair <int, Object[]> record in result) { User user = UserCatalog.getInstance().makeNewUser((int)record.Key, (String)record.Value[1], (String)record.Value[2], (String)record.Value[3]); UserIdentityMap.getInstance().addTo(user); } }
public List <User> getListOfUsers() { return(UserCatalog.getInstance().registeredUsers); }