Ejemplo n.º 1
0
 public static SignupCanvas GetInstance(Canvas canvas)
 {
     if (signupCanvas == null)
     {
         signupCanvas = new SignupCanvas(canvas);
     }
     return(signupCanvas);
 }
Ejemplo n.º 2
0
        public void SignupButtonUserData_Click(object sender, RoutedEventArgs args)
        {
            Front_End.SignupCanvas signupCanvas = Front_End.SignupCanvas.GetInstance(SignupCanvas);
            if (BackEndHelper.IsValidEmail(signupCanvas.GetEmail()) == false)
            {
                MessageBox.Show("Invalid Email");
                return;
            }
            if (signupCanvas.GetPassword().Length < 8)
            {
                MessageBox.Show("Passowrd length must be more than 8 characters");
                return;
            }
            if (signupCanvas.GetCreditCardSerial().Length > 20 || BackEndHelper.IsNumber(signupCanvas.GetCreditCardSerial()) == false)
            {
                MessageBox.Show("Invalid serial number");
                return;
            }
            if (signupCanvas.GetCreditCardCVV().Length > 4 || signupCanvas.GetCreditCardCVV().Length < 3 || BackEndHelper.IsNumber(signupCanvas.GetCreditCardCVV()) == false)
            {
                MessageBox.Show("Invalid cvv");
                return;
            }
            if (signupCanvas.GetExpirationDate() < DateTime.Today)
            {
                MessageBox.Show("Credit card expired");
                return;
            }
            User user = new User
                        (
                signupCanvas.GetUserName(),
                signupCanvas.GetEmail(),
                signupCanvas.GetName(),
                null,
                new CreditCard
                    (signupCanvas.GetCreditCardSerial(),
                    int.Parse(signupCanvas.GetCreditCardCVV()),
                    signupCanvas.GetExpirationDate()
                    )
                        );
            bool valid = DataModels.GetInstance().RegisterUser(user, signupCanvas.GetPassword());

            if (valid == false)
            {
                MessageBox.Show("User name taken");
                return;
            }
            Front_End.NavigationCanvas.GetInstance(NavigationCanvas).Hide();
            InitializeLoggedinNavigationCanvas(user);
            ActiveUser = user;

            CurrentCanvas.Hide();
            InitializeHomeCanvas();
        }