// this function return User object from the data layer. public static User getByEmail(string email) { UserD openedUser = DataLayerUser.open(email); User returnedUser = null; if (openedUser != null) { returnedUser = new User(openedUser.getEmail(), openedUser.getPassword()); returnedUser.setIsLoggedIn(openedUser.isLoggedIn()); returnedUser.setNumberOfTasksAdded(openedUser.getNumOfTasksAdded()); } return(returnedUser); }
// this function checks if the current user is already registerd if not save the user to the data. public InfoObject register() { InfoObject info; if (DataLayerUser.open(getEmail()) == null) { save(); Log.Info("The user " + getEmail() + " registered."); info = new InfoObject(true, "The user " + getEmail() + " registered."); return(info); } else { Log.Info("The user " + getEmail() + " can't register because this email is already in use."); info = new InfoObject(false, "The user " + getEmail() + " can't register because this email is already in use."); return(info); } }