public void SignIn() { if (!EmailValidator.Validate()) { return; } Guest guest; try { guest = Business.Guest(new Email(email.Text)); EmailValidator.ResetError(); } catch (InexistentEmailException ex) { EmailValidator.SetError(ex.Message); return; } if (!PasswordValidator.Validate()) { return; } try { GuestSession.SignIn(guest, password.Password); PasswordValidator.ResetError(); Frame.Navigate(new GuestPage(Business, GuestSession, Frame)); } catch (WrongPasswordException ex) { PasswordValidator.SetError(ex.Message); } }
public void SignIn() { if (!EmailValidator.Validate()) { return; } Admin admin; try { admin = Business.Admin(new Email(email.Text)); EmailValidator.ResetError(); } catch (InexistentEmailException ex) { EmailValidator.SetError(ex.Message); return; } if (!PasswordValidator.Validate()) { return; } try { AdminSession.SignIn(admin, password.Password); PasswordValidator.ResetError(); Frame.Navigate(new AdminPage(Business, Frame)); } catch (WrongPasswordException ex) { PasswordValidator.SetError(ex.Message); } }
public GuestSignInPage(IBusiness business, Session <Guest> guest_session, Frame frame) { InitializeComponent(); Business = business; guest_session.SignInPage = this; GuestSession = guest_session; Frame = frame; EmailValidator = new EmailValidator(email, email_error); PasswordValidator = new PasswordValidator(password, password_error); }
public AdminSignInPage(IBusiness business, Session <Admin> admin_session, Frame frame) { InitializeComponent(); Business = business; admin_session.SignInPage = this; AdminSession = admin_session; Frame = frame; EmailValidator = new EmailValidator(email, email_error); PasswordValidator = new PasswordValidator(password, password_error); }
public AddHostPage(IBusiness business, Frame frame, HostSignInPage host_sign_in_page) { InitializeComponent(); Business = business; Frame = frame; HostSignInPage = host_sign_in_page; EmailValidator = new EmailValidator(email, email_error); Validators = new List <IValidator>() { new RequiredTextValidator(first_name, first_name_error, control => Regex.Match(control.Text, @"^[a-z ,.'-]+$", RegexOptions.IgnoreCase).Success ? "" : "Error: Cannot have these symbols in your name." ), new RequiredTextValidator(last_name, last_name_error, control => Regex.Match(control.Text, @"^[a-z ,.'-]+$", RegexOptions.IgnoreCase).Success ? "" : "Error: Cannot have these symbols in your name." ), EmailValidator, new PhoneValidator(phone, phone_error), new PasswordValidator(password, password_error), new PasswordValidator(repeat_password, repeat_password_error, control => control.Password != password.Password ? "Error: Passwords do not match." : "" ), new IntValidator(bank_number, bank_number_error, true, 0, null, control => { try { control.Text = new ID(control.Text, 2); Business.BankBranches().First(branch => branch.BankID == bank_number.Text); return(""); } catch (IncorrectDigitsException) { return("Error: Bank number must be at most two digits."); } catch (FormatException) { return("Error: Could not parse the input as a bank number."); } catch (OverflowException) { return("Error: Number is too large to be a bank number."); } catch (InvalidOperationException) { return("Error: No bank with this number was found."); } } ), new IntValidator(branch_number, branch_number_error, true, 0, null, control => { try { control.Text = new ID(control.Text, 3); BankBranch = Business.BankBranches().First(branch => branch.BankID == bank_number.Text && branch.BranchID == control.Text); return(""); } catch (IncorrectDigitsException) { return("Error: Branch number must be at most three digits."); } catch (FormatException) { return("Error: Could not parse the input as a branch number."); } catch (OverflowException) { return("Error: Number is too large to be a branch number."); } catch (InvalidOperationException) { return("Error: No branch with this number was found for bank " + bank_number.Text + '.'); } } ), new IntValidator(account_number, account_number_error, true, 0, null, control => { try { control.Text = new ID(control.Text, 6); return(""); } catch (IncorrectDigitsException) { return("Error: Account number must be six digits."); } catch (FormatException) { return("Error: Could not parse the input as an account number."); } catch (OverflowException) { return("Error: Number is too large to be an account number."); } } ) }; }