예제 #1
0
        private void RegisterCommandExecute()
        {
            UserModel.Instance.Email = Email;
            if (UserModel.Instance.Email == null || UserModel.Instance.Password == null)
            {
                MessageBox.Show("Both email and password should be filled in.");
                return;
            }
            if (AccountManager.EmailExists(Email))
            {
                MessageBox.Show(string.Format("The email {0} already exists", Email));
                return;
            }
            var Validator = new PersonalAccountValidator().ValidatePassword(UserModel.Instance.Password);

            if (!Validator.IsValid)
            {
                MessageBox.Show(Validator.ValidationMessage);
                return;
            }
            if (SendEmailCode(window, Resources.RegisterAccountEmailSubject, Resources.GenericEmailContent))
            {
                //CloseAction?.Invoke();
            }
        }
예제 #2
0
        private void ResetCommandExecute()
        {
            if (UserModel.Instance.Password == null)
            {
                return;
            }
            var Validator = new PersonalAccountValidator().ValidatePassword(UserModel.Instance.Password);

            if (!Validator.IsValid)
            {
                MessageBox.Show(Validator.ValidationMessage);
            }
            else
            {
                AccountManager.ChangePassword(window, UserModel.Instance.Email, UserModel.Instance.Password);
                //CloseAction?.Invoke();
            }
        }
예제 #3
0
        public bool SendEmailCode(Window window, string emailSubject, string emailContent)
        {
            var confirmationCode = new Random().Next(100000, 999999).ToString();

            emailContent += confirmationCode;
            var Validator = new PersonalAccountValidator().ValidateEmail(UserModel.Instance.Email, emailSubject, emailContent);

            if (UserModel.Instance.Email == null || !Validator.IsValid)
            {
                MessageBox.Show(Validator.ValidationMessage);
                return(false);
            }
            var confirmationCodeViewModel = new ConfirmationCodeViewModel(window, confirmationCode);

            WindowManager.ChangeWindowContent(window, confirmationCodeViewModel, Resources.ConfirmationCodeWindowTitle, Resources.ConfirmationCodeControlPath);

            if (confirmationCodeViewModel.CloseAction == null)
            {
                confirmationCodeViewModel.CloseAction = () => window.Close();
            }
            return(true);
        }