Esempio n. 1
0
        public void AddValidateDetails()
        {
            var databaseContext = new UserRegistrationDBEntities();
            var user            = new tableUser()
            {
                FirstName = first.Text.Trim(),
                LastName  = last.Text.Trim(),
                Contact   = number.Text.Trim(),
                Address   = location.Text.Trim(),
                Username  = alias.Text.Trim(),
                Password  = pass.Text.Trim(),
                Email     = mail.Text.Trim()
            };

            databaseContext.tableUsers.Add(user);
            databaseContext.SaveChanges();
            MessageBox.Show("Registered successfully");
            registered = true;
            Login.SetPrincipleUser(user);
            SharedFunctions.Clear(this);
            SharedFunctions.GoHomeOnly(this);
        }
Esempio n. 2
0
        private void Send_Click(object sender, RoutedEventArgs e)
        {
            bool passedEmptyBoxesStage = SharedFunctions.PassedEmpty(this);
            var  emailAtr = new EmailAddressAttribute();

            if (passedEmptyBoxesStage)
            {
                if (!number.Text.All(Char.IsDigit))
                {
                    SharedFunctions.AddErrors(number, "Contact: Type in only numbers");
                }

                if (pass.Text != confirm.Text)
                {
                    SharedFunctions.AddErrors(pass, "Password confirmation does not match");
                }

                if (emailAtr.IsValid(mail.Text) == false)
                {
                    SharedFunctions.AddErrors(mail, "Please write your email in the format: [email protected]");
                }

                if (SharedFunctions.GetFoundErrors().Count() == 0)
                {
                    AddValidateDetails();
                }
                else
                {
                    SharedFunctions.CheckForErrors();
                }
            }
            //All fields where blank, leave all red, but change as input
            else
            {
                SharedFunctions.Clear(this);
            }
        }