Ejemplo n.º 1
0
        public static string NewPhoneChecker()
        {
            // phone pattern complete
            string phonePattern = RegexAndLoginExpressions.phoneRegex();
            Match  rxPhone      = Regex.Match("", phonePattern);
            string phone        = "";

            while (!rxPhone.Success)
            {
                // Phone Number
                Console.Clear();
                Console.WriteLine("\n ---- Phone 10 digits not starting with 0 ----");
                RegexAndLoginExpressions.quitPrompt();
                phone = Console.ReadLine();
                if (phone.Equals("quit"))
                {
                    return("quit");
                }
                rxPhone = Regex.Match(phone, phonePattern);
                phone   = Regex.Replace(phone, "[/-]", "");
                if (phone.StartsWith("0"))
                {
                    rxPhone = Regex.Match("123", phonePattern);
                }
            }
            phone = Regex.Replace(phone, "[/-]", "");
            return(phone);
        }
        public static string NewLastNameChecker()
        {
            string namePattern = RegexAndLoginExpressions.nameRegex();
            Match  rxLname     = Regex.Match("", namePattern);
            string lname       = "";

            while (!rxLname.Success)
            {
                // Last Name
                Console.Clear();
                Console.WriteLine("\n ---- last name ----");
                RegexAndLoginExpressions.quitPrompt();
                lname = Console.ReadLine();
                if (lname.Equals("quit"))
                {
                    return("quit");
                }
                rxLname = Regex.Match(lname, namePattern);
            }
            return(lname);
        }
        public static string NewEmailChecker()
        {
            string emailChk = RegexAndLoginExpressions.emailRegex();
            Match  mxEmail  = Regex.Match("", emailChk);
            string email    = "";

            while (!mxEmail.Success)
            {
                // Email
                Console.Clear();
                Console.WriteLine("\n  ---- email ----");
                RegexAndLoginExpressions.quitPrompt();
                email = Console.ReadLine();
                if (email.Equals("quit"))
                {
                    return("quit");
                }
                mxEmail = Regex.Match(email, emailChk);
            }
            return(email);
        }
        public static string NewFirstNameChecker()
        {
            string namePattern = RegexAndLoginExpressions.nameRegex();
            // phone pattern complete
            Match  rxFname = Regex.Match("", namePattern);
            string fname   = "";

            while (!rxFname.Success)
            {
                // First Name
                Console.Clear();
                Console.WriteLine("\n ---- first name ----");
                RegexAndLoginExpressions.quitPrompt();
                fname = Console.ReadLine();
                if (fname.Equals("quit"))
                {
                    return("quit");
                }
                rxFname = Regex.Match(fname, namePattern);
            }
            return(fname);
        }
Ejemplo n.º 5
0
        public static string NewPassChecker()
        {
            // password
            string passCheck = RegexAndLoginExpressions.passRegex();

            // phone pattern complete
            string password = "";
            Match  rxPass   = Regex.Match("", passCheck);

            while (!rxPass.Success)
            {
                // First Name
                Console.Clear();
                Console.WriteLine("\n ---- password ----");
                RegexAndLoginExpressions.quitPrompt();
                password = Console.ReadLine();
                if (password.Equals("quit"))
                {
                    return("quit");
                }
                rxPass = Regex.Match(password, passCheck);
            }
            return(password);
        }
        public static bool CreateNewUserPrompt(Abstractions.IRepositoryCustomer <Customer1> repo)
        {
            // Check for valid email
            string email = EmailCheck.NewEmailChecker();

            if (RegexAndLoginExpressions.safeWord(email))
            {
                return(false);
            }
            // Check for valid password
            string password = PassCheck.NewPassChecker();

            if (RegexAndLoginExpressions.safeWord(password))
            {
                return(false);
            }
            // Check for valid first name
            string fname = FirstNameCheck.NewFirstNameChecker();

            if (RegexAndLoginExpressions.safeWord(fname))
            {
                return(false);
            }
            // Check for valid last name
            string lname = LastNameCheck.NewLastNameChecker();

            if (RegexAndLoginExpressions.safeWord(lname))
            {
                return(false);
            }
            // Check for valid phone
            string phone = PhoneCheck.NewPhoneChecker();

            if (RegexAndLoginExpressions.safeWord(phone))
            {
                return(false);
            }

            // Check if customer already exists
            if (CxAlreadyExists.CxAlreadyExistsChecker(repo, email, phone))
            {
                Console.Clear();
                Console.WriteLine("Email or phone# already taken please go back and login.");
                Thread.Sleep(1500);
                return(false);
            }

            Console.Clear();
            Console.WriteLine("Created your account! [{0}]", email);
            Thread.Sleep(800);
            Random    random = new Random();
            Customer1 Cu     = new Customer1()
            {
                Id       = random.Next(1000000000, 2000000000),
                Fname    = fname,
                Lname    = lname,
                Email    = email,
                UserPass = password,
                Phone    = Convert.ToInt64(phone)
            };

            repo.CreateCustomer(Cu);
            return(true);
        }