public void AddNewUser(User pUser)
        {
            //add to array

            int arrayLength = usersArray.Length;
            Array.Resize(ref usersArray, arrayLength + 1);

            usersArray[arrayLength] = pUser.Email;

            foreach (string i in usersArray)
            {
                Console.WriteLine("Array email address is : " +  i);
            }

            //add to dictionary
            usersMap.Add(pUser.Email, pUser.Password);
            foreach (KeyValuePair<string, string> i in usersMap)
            {
                Console.WriteLine("Dictionary email address is : " + i.Key + "password is : " + i.Value);
            }

            //add to list
            usersList.Add(pUser.Email);
            foreach (string i in usersList)
            {
                Console.WriteLine("List email address is : " + i);
            }
        }
Exemplo n.º 2
0
        public User AddNewUser(User pUser)
        {
            //Uncomment the following for SQLLite Database,
               //mapper.addNewUser(pUser);

            mapperNonDb.AddNewUser(pUser);

            return pUser;
        }
Exemplo n.º 3
0
        public bool ValidateUser(User pUser)
        {
            bool isValid = false;

            //Uncomment the following for SQLLite Database, TODO not yet finished
            //int valid =  mapper.validateUser(pUser);
            //if(valid >=1)
            //{
            //  isValid = true;
            //}

            isValid = mapperNonDb.ValidateUser(pUser);
            return isValid;
        }
        private bool ValidateUserByArray(User pUser)
        {
            bool valid = false;

            foreach (string i in usersArray)
            {
                if (i.Equals(pUser.Email))
                {
                    valid = true;
                    break;
                }
            }
            return valid;
        }
        public bool ValidateUser(User pUser)
        {
            bool isUserValid = false;

            bool bol1 = ValidateUserByArray(pUser);
            bool bol2 = ValidateUserByMap (pUser);
            bool bol3 = ValidateUserByList(pUser);

            if(bol1 && bol2 && bol3)
            {
                isUserValid = true;
            }

            return isUserValid;
        }
Exemplo n.º 6
0
        public User AddNewUser(User pUser)
        {
            BuildSqlLiteDb sql = new BuildSqlLiteDb();
            // create a new database connection:
            sqlConnection = sql.getConnection();
            sqlConnection.Open();

            sqlCommand = sqlConnection.CreateCommand();

            sqlCommand.CommandText = "INSERT INTO USER (name,email,password) VALUES(@name, @email, @password)";

            sqlCommand.Parameters.Add(new SQLiteParameter("@name", pUser.Name));
            sqlCommand.Parameters.Add(new SQLiteParameter("@email", pUser.Email));
            sqlCommand.Parameters.Add(new SQLiteParameter("@password", pUser.Password));

            sqlCommand.ExecuteNonQuery();
            Console.Write("User inserted : " + pUser.toString());
            sqlConnection.Close();

            return pUser;
        }
Exemplo n.º 7
0
        public int ValidateUser(User pUser)
        {
            BuildSqlLiteDb sql = new BuildSqlLiteDb();
            // create a new database connection:
            sqlConnection = sql.getConnection();
            sqlConnection.Open();

            sqlCommand = sqlConnection.CreateCommand();

            sqlCommand.CommandText = "select count(1) from user where email = @email and password = @password";

            sqlCommand.Parameters.Add(new SQLiteParameter("@email", pUser.Email));
            sqlCommand.Parameters.Add(new SQLiteParameter("@password", pUser.Password));
            sqlReader = sqlCommand.ExecuteReader();

            int valid = 1;

            //TODO - read results

            sqlConnection.Close();

            return valid;
        }
        private User CreateLoginUser()
        {
            User currentUser = new User();
            currentUser.Email = loginEmail_Input.Text;
            Console.WriteLine("Email is " + currentUser.Email);
            currentUser.Password = loginPassword_Input.Text;
            Console.WriteLine("Password is " + currentUser.Password);

            return currentUser;
        }
        private bool ValidateEmailFormat(User pUser)
        {
            bool isValid = false;

            string email = pUser.Email;
            System.Text.RegularExpressions.Regex regex = new Regex(@"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$");
            Match match = regex.Match(email);
            if (match.Success)
            {
                Console.Write(email + " is valid");
                isValid = true;
            }
            else
            {
                Console.Write(email + " is invalid");
                errorMessages.Add("Email format is incorrect");
            }

            return isValid;
        }
Exemplo n.º 10
0
        private bool Validate(User currentUser)
        {
            bool isValid = true;

            if( !ValidateEmailFormat(currentUser) || !DoPasswordsMatch() )
            {
                foreach(string i in errorMessages)
                {
                    validationErrors.View = View.List;
                    this.validationErrors.Items.Add(i);
                }
                isValid = false;
            }

            return isValid;
        }
Exemplo n.º 11
0
        private User CreateSignUpUser()
        {
            User currentUser = new User();
            currentUser = new User();
            currentUser.Name = name_input.Text;
            Console.WriteLine("Name is " + currentUser.Name);
            currentUser.Email = email_input.Text;
            Console.WriteLine("Email is " + currentUser.Email);
            currentUser.Password = password_input.Text;
            Console.WriteLine("Password is " + currentUser.Password);

            return currentUser;
        }
        private bool ValidateUserByMap(User pUser)
        {
            bool valid = false;

            foreach (KeyValuePair<string, string> i in usersMap)
            {
                if (i.Key.Equals(pUser.Email) && i.Value.Equals(pUser.Password))
                {
                    valid = true;
                    break;
                }
            }
            return valid;
        }