/// <summary>
        /// Returns all users and their data in the database in the form of a string
        /// </summary>
        /// /// <returns>The list of users</returns>
        public IEnumerable <IUser> ListUsers()
        {
            List <IUser> allUserModels = new List <IUser>();

            for (int i = 1; i <= database.RetrieveNumberOfRowsInTable(); i++)
            {
                SetRowToObject(i);
                IUser userModel = new User
                {
                    UserName = user.UserName,
                    Email    = user.Email,
                    Password = user.Password,
                    Score    = user.Score
                };
                allUserModels.Add(userModel);
            }
            return(allUserModels);
        }
Beispiel #2
0
        /// <summary>
        /// Validates email and password for login and retrieves user data.
        /// </summary>
        /// <param name="email">The user's email</param>
        /// <param name="password">The user's password</param>
        /// <returns></returns>
        public Boolean AuthenticateUser(string email, string password)
        {
            string userData = "";

            string[] splitRow;
            for (int i = 1; i <= database.RetrieveNumberOfRowsInTable(); i++)
            {
                userData = database.RetrieveTableRow(database.TableName, i);
                splitRow = userData.Split(separator: '\n');
                if (splitRow[1].Equals(email) && splitRow[2].Equals(password))
                {
                    user.UserName = splitRow[0];
                    user.Email    = splitRow[1];
                    user.Password = splitRow[2];
                    user.Score    = splitRow[3];
                    return(true);
                }
            }

            return(false);
        }