/// <summary>
        /// Changes the password.
        /// </summary>
        /// <param name="changePassword">The change password.</param>
        /// <param name="email">The email.</param>
        /// <returns></returns>
        public string ChangePassword(IChangePasswordView changePassword, string email)
        {
            var result = string.Empty;

            try
            {
                using (
                    var dbContext = (PitalyticsEntities)dbContextFactory.GetDbContext())
                {
                    var userInfo = this.GetUserByEmail(email);
                    if (userInfo != null)
                    {
                        userInfo.Password = changePassword.NewPassword;
                    }
                    dbContext.SaveChanges();
                }
            }
            catch (Exception e)
            {
                result = string.Format("Change Password - {0} , {1}", e.Message,
                                       e.InnerException != null ? e.InnerException.Message : "");
            }


            return(result);

            ;
        }
예제 #2
0
        /// <summary>
        /// Saves the change password.
        /// </summary>
        /// <param name="changePasswordView">The change password view.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException">changePasswordView</exception>
        public string SaveChangePassword(IChangePasswordView changePasswordView)
        {
            if (changePasswordView == null)
            {
                throw new ArgumentNullException(nameof(changePasswordView));
            }

            var result = string.Empty;

            try
            {
                using (
                    var dbContext = (HRMSEntities)this.dbContextFactory.GetDbContext(ObjectContextType.HRMS))
                {
                    var userInfo = dbContext.Users.SingleOrDefault(p => p.Email.Equals(changePasswordView.Email));

                    userInfo.Password        = changePasswordView.NewPassword;
                    userInfo.IsResetPassword = true;

                    dbContext.SaveChanges();
                }
            }
            catch (Exception e)
            {
                result = string.Format("Save Change Password - {0} , {1}", e.Message,
                                       e.InnerException != null ? e.InnerException.Message : "");
            }

            return(result);
        }
        public ChangePasswordPresenter(IChangePasswordView view)
        {
            _view       = view;
            _repository = new SecuritieSrv();

            _view.Save += Save;
        }
예제 #4
0
        /// <summary>
        /// Gets the change password page.
        /// </summary>
        /// <param name="Email">The email.</param>
        /// <param name="NewPassword">The new password.</param>
        /// <param name="ConfirmNewPassword">The confirm new password.</param>
        /// <returns></returns>
        public string ProcessChangePasswordPage(IChangePasswordView changePasswordView)
        {
            string message;

            bool isDataOkay = false;

            if (changePasswordView == null)
            {
                throw new ArgumentNullException(nameof(changePasswordView));
            }

            isDataOkay = (this.accountRepository.GetChangePasswordByCode(changePasswordView.Code) == null) ? false : true;

            if (!isDataOkay)
            {
                message = Messages.EmailDoesNotExist;

                return(message);
            }

            changePasswordView.NewPassword = this.encryptionService.Encrypt(changePasswordView.NewPassword);

            message = this.accountRepository.SaveChangePassword(changePasswordView);

            return(message);
        }
예제 #5
0
 public ChangePasswordViewModel(IChangePasswordView view, IBusinessLogic logic, Employee currentUser)
 {
     this._businessLogic = logic;
     this._view          = view;
     this._view.SetViewModel(this);
     this.CurrentUser = currentUser;
     this.IsActive    = true;
 }
예제 #6
0
        /// <summary>
        /// Gets the change password page.
        /// </summary>
        /// <param name="changePasswordView">The change password view.</param>
        /// <param name="messagee">The messagee.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException">changePasswordView</exception>
        public IChangePasswordView GetChangePasswordPage(IChangePasswordView changePasswordView, string messagee)
        {
            if (changePasswordView == null)
            {
                throw new ArgumentNullException(nameof(changePasswordView));
            }

            return(accountViewsModelFactory.CreateChangePasswordPageView(changePasswordView, messagee));
        }
예제 #7
0
        /// <summary>
        /// Creates the change password page view.
        /// </summary>
        /// <param name="changePasswordView">The change password view.</param>
        /// <param name="processingMessage">The processing message.</param>
        /// <returns></returns>
        public IChangePasswordView CreateChangePasswordPageView(IChangePasswordView changePasswordView, string processingMessage)
        {
            if (changePasswordView == null)
            {
                throw new ArgumentNullException(nameof(changePasswordView));
            }

            changePasswordView.ProcessingMessage = processingMessage;

            return(changePasswordView);
        }
예제 #8
0
        public ActionResult ChangePassword(IChangePasswordView changePassword)
        {
            if (changePassword == null)
            {
                throw new ArgumentNullException(nameof(changePassword));
            }
            var changePasswordInfo = this.accountService.ChangePassword(changePassword);

            if (string.IsNullOrEmpty(changePasswordInfo.ProcessingMessage))
            {
                changePasswordInfo.ProcessingMessage = "Your Password Saved Successfully";
            }

            return(View("ChangePasssword", changePassword));
        }
        /// <summary>
        /// Changes the password.
        /// </summary>
        /// <param name="changePassword">The change password.</param>
        /// <param name="processingMessage">The processing message.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException">changePassword</exception>
        public IChangePasswordView ChangePassword(IChangePasswordView changePassword, string processingMessage)
        {
            if (changePassword == null)
            {
                throw new ArgumentNullException(nameof(changePassword));
            }

            var view = new ChangePasswordView
            {
                ProcessingMessage = processingMessage,
                NewPassword       = changePassword.NewPassword,
                OldPassword       = changePassword.OldPassword,
            };

            return(view);
        }
예제 #10
0
        /*=================================================================================================
        *       PROPERTIES
        *================================================================================================*/
        /*PUBLIC******************************************************************************************/

        /*PRIVATE*****************************************************************************************/

        /*=================================================================================================
        *       CONSTRUCTORS
        *================================================================================================*/
        public ChangePasswordPresenter(IChangePasswordView changePasswordView, IPasswordService passwordService)
        {
            if (changePasswordView == null)
            {
                throw new ArgumentNullException(nameof(changePasswordView));
            }

            if (passwordService == null)
            {
                throw new ArgumentNullException(nameof(passwordService));
            }

            _changePasswordView = changePasswordView;
            _passwordService    = passwordService;

            _changePasswordView.ChangePasswordEvent      += ModifyPassword;
            _changePasswordView.PasswordTextChangedEvent += PasswordTextChanged;
            _changePasswordView.GenerateNewPasswordEvent += GeneratePassword;
        }
예제 #11
0
        /// <summary>
        /// Changes the password.
        /// </summary>
        /// <param name="changePassword">The change password.</param>
        /// <returns></returns>
        public IChangePasswordView ChangePassword(IChangePasswordView changePassword)
        {
            var processingMessage = string.Empty;
            var email             = (string)session.GetSessionValue(SessionKey.Email);
            var userInfo          = this.accountRepository.GetUserByEmail(email);
            var decryptedPassword = this.encryptionService.Decrypt(userInfo.Password);

            if (!changePassword.OldPassword.Equals(decryptedPassword))
            {
                processingMessage = Messages.PasswordNotEqual;
            }
            else
            {
                var encrypptedPassword = this.encryptionService.Encrypt(changePassword.NewPassword);
                changePassword.NewPassword = encrypptedPassword;
                var returnInfo = this.accountRepository.ChangePassword(changePassword, email);
                returnInfo = processingMessage;
            }

            return(this.accountViewsModelFactory.ChangePassword(changePassword, processingMessage));
        }
예제 #12
0
        /// <summary>
        /// Creates the authentication page.
        /// </summary>
        /// <param name="registrationView">The registration view.</param>
        /// <param name="logOnView">The log on view.</param>
        /// <param name="changePasswordView">The change password view.</param>
        /// <returns></returns>
        public IHomeView CreateAuthenticationPage(IRegistrationView registrationView, ILogOnView logOnView, IChangePasswordView changePasswordView, string processingMessage)
        {
            var model = new HomeModelView
            {
                Registration      = registrationView,
                LogOn             = logOnView,
                ChangePassword    = changePasswordView,
                ProcessingMessage = processingMessage,
            };

            return(model);
        }
예제 #13
0
 /// <summary>
 /// Gets the change password.
 /// </summary>
 /// <param name="changePassword">The change password.</param>
 /// <returns></returns>
 public IChangePasswordView GetChangePassword(IChangePasswordView changePassword, string message)
 {
     return(accountViewsModelFactory.CreateChangePasswordView(changePassword, message));
 }
예제 #14
0
 public ChangePasswordPresenter(IChangePasswordView view, IChangePasswordModel model)
 {
     _view  = view;
     _model = model;
 }
 public void Init()
 {
     _fakeView  = Substitute.For <IChangePasswordView>();
     _fakeModel = Substitute.For <IChangePasswordModel>();
     _uut       = new ChangePasswordPresenter(_fakeView, _fakeModel);
 }
예제 #16
0
 public ChangePasswordPresenter(IChangePasswordView view)
 {
     this.view            = view;
     view.ChangePassword += View_ChangePassword;
 }
예제 #17
0
        /*=================================================================================================
        *       CONSTRUCTORS
        *================================================================================================*/
        public MainView(ILoginView loginView, IChangePasswordView changePasswordView, IEditUserView editUserView)
        {
            _loginView          = loginView ?? throw new ArgumentNullException(nameof(loginView));
            _changePasswordView = changePasswordView ?? throw new ArgumentNullException(nameof(changePasswordView));
            _editUserView       = editUserView ?? throw new ArgumentNullException(nameof(editUserView));

            _loginView.LoginSuccessfulEvent += DisplayLoginSuccessful;
            _dgvPasswordList = new BindingList <Password>();
            InitializeComponent();

            #region UI
            // Configure form UI
            BackColor       = UIHelper.GetColorFromCode(UIColors.DefaultBackgroundColor);
            FormBorderStyle = FormBorderStyle.None;

            // Configure labels
            label1.Font      = UIHelper.GetFont(UIFontSizes.DefaultFontSize);
            label1.ForeColor = UIHelper.GetColorFromCode(UIColors.DefaultFontColor);

            label2.Font      = UIHelper.GetFont(UIFontSizes.DefaultFontSize);
            label2.ForeColor = UIHelper.GetColorFromCode(UIColors.DefaultFontColor);

            label3.Font      = UIHelper.GetFont(UIFontSizes.DefaultFontSize);
            label3.ForeColor = UIHelper.GetColorFromCode(UIColors.DefaultFontColor);

            label4.Font      = UIHelper.GetFont(UIFontSizes.DefaultFontSize);
            label4.ForeColor = UIHelper.GetColorFromCode(UIColors.DefaultFontColor);

            label5.Font      = UIHelper.GetFont(UIFontSizes.DefaultFontSize);
            label5.ForeColor = UIHelper.GetColorFromCode(UIColors.DefaultFontColor);

            label6.Font      = UIHelper.GetFont(UIFontSizes.DefaultFontSize);
            label6.ForeColor = UIHelper.GetColorFromCode(UIColors.DefaultFontColor);

            filterLabel.Font      = UIHelper.GetFont(UIFontSizes.DefaultFontSize);
            filterLabel.ForeColor = UIHelper.GetColorFromCode(UIColors.DefaultFontColor);

            // Configure menu strip
            menuStrip.BackColor                       = UIHelper.GetColorFromCode(UIColors.DefaultBackgroundColor);
            menuStrip.ForeColor                       = UIHelper.GetColorFromCode(UIColors.DefaultFontColor);
            menuStrip.Font                            = UIHelper.GetFont(UIFontSizes.DefaultFontSize);
            menuStrip.MenuItemSelectedColor           = UIHelper.GetColorFromCode(UIColors.ControlHighLightColor);
            menuStrip.MenuItemBackgroundColor         = UIHelper.GetColorFromCode(UIColors.ControlBackgroundColor);
            loginToolStripMenuItem.BackColor          = UIHelper.GetColorFromCode(UIColors.ControlBackgroundColor);
            loginToolStripMenuItem.ForeColor          = UIHelper.GetColorFromCode(UIColors.DefaultFontColor);
            loginToolStripMenuItem.Font               = UIHelper.GetFont(UIFontSizes.DefaultFontSize);
            accountToolStripMenuItem.BackColor        = UIHelper.GetColorFromCode(UIColors.ControlBackgroundColor);
            accountToolStripMenuItem.ForeColor        = UIHelper.GetColorFromCode(UIColors.DefaultFontColor);
            accountToolStripMenuItem.Font             = UIHelper.GetFont(UIFontSizes.DefaultFontSize);
            editToolStripMenuItem.BackColor           = UIHelper.GetColorFromCode(UIColors.ControlBackgroundColor);
            editToolStripMenuItem.ForeColor           = UIHelper.GetColorFromCode(UIColors.DefaultFontColor);
            editToolStripMenuItem.Font                = UIHelper.GetFont(UIFontSizes.DefaultFontSize);
            editToolStripMenuItem.Enabled             = false;
            deleteToolStripMenuItem.BackColor         = UIHelper.GetColorFromCode(UIColors.ControlBackgroundColor);
            deleteToolStripMenuItem.ForeColor         = UIHelper.GetColorFromCode(UIColors.DefaultFontColor);
            deleteToolStripMenuItem.Font              = UIHelper.GetFont(UIFontSizes.DefaultFontSize);
            deleteToolStripMenuItem.Enabled           = false;
            changePasswordToolStripMenuItem.BackColor = UIHelper.GetColorFromCode(UIColors.ControlBackgroundColor);
            changePasswordToolStripMenuItem.ForeColor = UIHelper.GetColorFromCode(UIColors.DefaultFontColor);
            changePasswordToolStripMenuItem.Font      = UIHelper.GetFont(UIFontSizes.DefaultFontSize);
            changePasswordToolStripMenuItem.Enabled   = false;

            // Configure buttons
            addButton.BackColor = UIHelper.GetColorFromCode(UIColors.ControlBackgroundColor);
            addButton.ForeColor = UIHelper.GetColorFromCode(UIColors.DefaultFontColor);
            addButton.FlatStyle = FlatStyle.Flat;
            addButton.Font      = UIHelper.GetFont(UIFontSizes.ButtonFontSize);
            addButton.FlatAppearance.BorderColor = UIHelper.GetColorFromCode(UIColors.DefaultBackgroundColor);
            addButton.FlatAppearance.BorderSize  = 1;

            deleteButton.BackColor = UIHelper.GetColorFromCode(UIColors.ControlBackgroundColor);
            deleteButton.ForeColor = UIHelper.GetColorFromCode(UIColors.DefaultFontColor);
            deleteButton.FlatStyle = FlatStyle.Flat;
            deleteButton.Font      = UIHelper.GetFont(UIFontSizes.ButtonFontSize);
            deleteButton.FlatAppearance.BorderColor = UIHelper.GetColorFromCode(UIColors.DefaultBackgroundColor);
            deleteButton.FlatAppearance.BorderSize  = 1;

            editButton.BackColor = UIHelper.GetColorFromCode(UIColors.ControlBackgroundColor);
            editButton.ForeColor = UIHelper.GetColorFromCode(UIColors.DefaultFontColor);
            editButton.FlatStyle = FlatStyle.Flat;
            editButton.Font      = UIHelper.GetFont(UIFontSizes.ButtonFontSize);
            editButton.FlatAppearance.BorderColor = UIHelper.GetColorFromCode(UIColors.DefaultBackgroundColor);
            editButton.FlatAppearance.BorderSize  = 1;

            editCancelButton.BackColor = UIHelper.GetColorFromCode(UIColors.ControlBackgroundColor);
            editCancelButton.ForeColor = UIHelper.GetColorFromCode(UIColors.DefaultFontColor);
            editCancelButton.FlatStyle = FlatStyle.Flat;
            editCancelButton.Font      = UIHelper.GetFont(UIFontSizes.ButtonFontSize);
            editCancelButton.FlatAppearance.BorderColor = UIHelper.GetColorFromCode(UIColors.DefaultBackgroundColor);
            editCancelButton.FlatAppearance.BorderSize  = 1;
            editCancelButton.Enabled = false;
            editCancelButton.Visible = false;

            closeButton.BackColor = UIHelper.GetColorFromCode(UIColors.ControlBackgroundColor);
            closeButton.ForeColor = UIHelper.GetColorFromCode(UIColors.DefaultFontColor);
            closeButton.Font      = UIHelper.GetFont(UIFontSizes.CloseButtonFontSize);

            minimizeButton.BackColor = UIHelper.GetColorFromCode(UIColors.ControlBackgroundColor);
            minimizeButton.ForeColor = UIHelper.GetColorFromCode(UIColors.DefaultFontColor);
            minimizeButton.Font      = UIHelper.GetFont(UIFontSizes.CloseButtonFontSize);

            // Configure textbox
            applicationTextBox.BackColor   = UIHelper.GetColorFromCode(UIColors.ControlBackgroundColor);
            applicationTextBox.ForeColor   = UIHelper.GetColorFromCode(UIColors.DefaultFontColor);
            applicationTextBox.BorderStyle = BorderStyle.FixedSingle;
            applicationTextBox.Font        = UIHelper.GetFont(UIFontSizes.TextBoxFontSize);

            usernameTextBox.BackColor   = UIHelper.GetColorFromCode(UIColors.ControlBackgroundColor);
            usernameTextBox.ForeColor   = UIHelper.GetColorFromCode(UIColors.DefaultFontColor);
            usernameTextBox.BorderStyle = BorderStyle.FixedSingle;
            usernameTextBox.Font        = UIHelper.GetFont(UIFontSizes.TextBoxFontSize);

            emailTextBox.BackColor   = UIHelper.GetColorFromCode(UIColors.ControlBackgroundColor);
            emailTextBox.ForeColor   = UIHelper.GetColorFromCode(UIColors.DefaultFontColor);
            emailTextBox.BorderStyle = BorderStyle.FixedSingle;
            emailTextBox.Font        = UIHelper.GetFont(UIFontSizes.TextBoxFontSize);

            descriptionTextBox.BackColor   = UIHelper.GetColorFromCode(UIColors.ControlBackgroundColor);
            descriptionTextBox.ForeColor   = UIHelper.GetColorFromCode(UIColors.DefaultFontColor);
            descriptionTextBox.BorderStyle = BorderStyle.FixedSingle;
            descriptionTextBox.Font        = UIHelper.GetFont(UIFontSizes.TextBoxFontSize);

            passphraseTextBox.BackColor   = UIHelper.GetColorFromCode(UIColors.ControlBackgroundColor);
            passphraseTextBox.ForeColor   = UIHelper.GetColorFromCode(UIColors.DefaultFontColor);
            passphraseTextBox.BorderStyle = BorderStyle.FixedSingle;
            passphraseTextBox.Font        = UIHelper.GetFont(UIFontSizes.TextBoxFontSize);

            websiteTextBox.BackColor   = UIHelper.GetColorFromCode(UIColors.ControlBackgroundColor);
            websiteTextBox.ForeColor   = UIHelper.GetColorFromCode(UIColors.DefaultFontColor);
            websiteTextBox.BorderStyle = BorderStyle.FixedSingle;
            websiteTextBox.Font        = UIHelper.GetFont(UIFontSizes.TextBoxFontSize);

            filterTextBox.BackColor   = UIHelper.GetColorFromCode(UIColors.ControlBackgroundColor);
            filterTextBox.ForeColor   = UIHelper.GetColorFromCode(UIColors.DefaultFontColor);
            filterTextBox.BorderStyle = BorderStyle.FixedSingle;
            filterTextBox.Font        = UIHelper.GetFont(UIFontSizes.TextBoxFontSize);

            // Configure combo box
            filterComboBox.BackColor      = UIHelper.GetColorFromCode(UIColors.ControlBackgroundColor);
            filterComboBox.ForeColor      = UIHelper.GetColorFromCode(UIColors.DefaultFontColor);
            filterComboBox.Font           = UIHelper.GetFont(UIFontSizes.TextBoxFontSize);
            filterComboBox.DataSource     = Enum.GetValues(typeof(PasswordFilterOption));
            filterComboBox.DropDownStyle  = ComboBoxStyle.DropDownList;
            filterComboBox.HighlightColor = UIHelper.GetColorFromCode(UIColors.ControlHighLightColor);
            filterComboBox.BorderColor    = UIHelper.GetColorFromCode(UIColors.ControlBackgroundColor);

            // Configure status strip
            statusStrip1.BackColor = UIHelper.GetColorFromCode(UIColors.DefaultBackgroundColor);
            statusStrip1.ForeColor = UIHelper.GetColorFromCode(UIColors.DefaultFontColor);
            statusStrip1.Font      = UIHelper.GetFont(UIFontSizes.TextBoxFontSize);

            // Confgiure data grid view
            passwordDataGridView.BorderStyle                                      = BorderStyle.None;
            passwordDataGridView.SelectionMode                                    = DataGridViewSelectionMode.FullRowSelect;
            passwordDataGridView.MultiSelect                                      = false;
            passwordDataGridView.ReadOnly                                         = true;
            passwordDataGridView.BackgroundColor                                  = UIHelper.GetColorFromCode(UIColors.DefaultBackgroundColor);
            passwordDataGridView.RowsDefaultCellStyle.Font                        = UIHelper.GetFont(UIFontSizes.DefaultFontSize);
            passwordDataGridView.RowsDefaultCellStyle.ForeColor                   = UIHelper.GetColorFromCode(UIColors.DefaultFontColor);
            passwordDataGridView.RowsDefaultCellStyle.BackColor                   = Color.FromArgb(65, 65, 65);
            passwordDataGridView.AlternatingRowsDefaultCellStyle.BackColor        = Color.FromArgb(85, 85, 85);
            passwordDataGridView.CellBorderStyle                                  = DataGridViewCellBorderStyle.RaisedHorizontal;
            passwordDataGridView.AllowUserToOrderColumns                          = true;
            passwordDataGridView.DefaultCellStyle.SelectionBackColor              = Color.DarkGray;
            passwordDataGridView.DefaultCellStyle.SelectionForeColor              = Color.WhiteSmoke;
            passwordDataGridView.EnableHeadersVisualStyles                        = false;
            passwordDataGridView.ColumnHeadersBorderStyle                         = DataGridViewHeaderBorderStyle.None;
            passwordDataGridView.ColumnHeadersDefaultCellStyle.Font               = UIHelper.GetFont(UIFontSizes.DefaultFontSize);
            passwordDataGridView.ColumnHeadersDefaultCellStyle.BackColor          = UIHelper.GetColorFromCode(UIColors.DefaultBackgroundColor);
            passwordDataGridView.ColumnHeadersDefaultCellStyle.ForeColor          = UIHelper.GetColorFromCode(UIColors.DefaultFontColor);
            passwordDataGridView.ColumnHeadersDefaultCellStyle.SelectionBackColor = UIHelper.GetColorFromCode(UIColors.DefaultBackgroundColor);
            passwordDataGridView.ColumnHeadersDefaultCellStyle.SelectionForeColor = UIHelper.GetColorFromCode(UIColors.DefaultFontColor);
            passwordDataGridView.ScrollBars                                       = ScrollBars.None;
            passwordDataGridView.MouseWheel                                      += PasswordDataGridView_MouseWheel;

            // Configure context menu
            passwordContextMenuStrip = new AdvancedContextMenuStrip();
            var copyUsernameToolStripItem = new ToolStripMenuItem("Copy Username");
            copyUsernameToolStripItem.Font      = UIHelper.GetFont(UIFontSizes.DefaultFontSize);
            copyUsernameToolStripItem.BackColor = UIHelper.GetColorFromCode(UIColors.ControlBackgroundColor);
            copyUsernameToolStripItem.ForeColor = UIHelper.GetColorFromCode(UIColors.DefaultFontColor);
            copyUsernameToolStripItem.Image     = Bitmap.FromFile(Path.Combine(Environment.CurrentDirectory, @"Resources\icons8-copy-48.png"));
            passwordContextMenuStrip.Items.Add(copyUsernameToolStripItem);

            var copyPasswordToolStripItem = new ToolStripMenuItem("Copy Password");
            copyPasswordToolStripItem.Font      = UIHelper.GetFont(UIFontSizes.DefaultFontSize);
            copyPasswordToolStripItem.BackColor = UIHelper.GetColorFromCode(UIColors.ControlBackgroundColor);
            copyPasswordToolStripItem.ForeColor = UIHelper.GetColorFromCode(UIColors.DefaultFontColor);
            copyPasswordToolStripItem.Image     = Bitmap.FromFile(Path.Combine(Environment.CurrentDirectory, @"Resources\icons8-copy-48.png"));
            passwordContextMenuStrip.Items.Add(copyPasswordToolStripItem);

            var websiteToolStripItem = new ToolStripMenuItem("Visit Website");
            websiteToolStripItem.Font      = UIHelper.GetFont(UIFontSizes.DefaultFontSize);
            websiteToolStripItem.BackColor = UIHelper.GetColorFromCode(UIColors.ControlBackgroundColor);
            websiteToolStripItem.ForeColor = UIHelper.GetColorFromCode(UIColors.DefaultFontColor);
            websiteToolStripItem.Image     = Bitmap.FromFile(Path.Combine(Environment.CurrentDirectory, @"Resources\icons8-link-100.png"));
            passwordContextMenuStrip.Items.Add(websiteToolStripItem);

            var showPasswordToolStripItem = new ToolStripMenuItem("Show Password");
            showPasswordToolStripItem.Font      = UIHelper.GetFont(UIFontSizes.DefaultFontSize);
            showPasswordToolStripItem.BackColor = UIHelper.GetColorFromCode(UIColors.ControlBackgroundColor);
            showPasswordToolStripItem.ForeColor = UIHelper.GetColorFromCode(UIColors.DefaultFontColor);
            showPasswordToolStripItem.Image     = Bitmap.FromFile(Path.Combine(Environment.CurrentDirectory, @"Resources\icons8-show-property-60.png"));
            passwordContextMenuStrip.Items.Add(showPasswordToolStripItem);

            var editToolStripItem = new ToolStripMenuItem("Edit");
            editToolStripItem.Font      = UIHelper.GetFont(UIFontSizes.DefaultFontSize);
            editToolStripItem.BackColor = UIHelper.GetColorFromCode(UIColors.ControlBackgroundColor);
            editToolStripItem.ForeColor = UIHelper.GetColorFromCode(UIColors.DefaultFontColor);
            editToolStripItem.Image     = Bitmap.FromFile(Path.Combine(Environment.CurrentDirectory, @"Resources\icons8-edit-48.png"));
            passwordContextMenuStrip.Items.Add(editToolStripItem);

            var deleteToolStripItem = new ToolStripMenuItem("Delete");
            deleteToolStripItem.Font      = UIHelper.GetFont(UIFontSizes.DefaultFontSize);
            deleteToolStripItem.BackColor = UIHelper.GetColorFromCode(UIColors.ControlBackgroundColor);
            deleteToolStripItem.ForeColor = UIHelper.GetColorFromCode(UIColors.DefaultFontColor);
            deleteToolStripItem.Image     = Bitmap.FromFile(Path.Combine(Environment.CurrentDirectory, @"Resources\icons8-delete-60.png"));
            passwordContextMenuStrip.Items.Add(deleteToolStripItem);

            passwordContextMenuStrip.Items[0].Click += CopyUser_Click;
            passwordContextMenuStrip.Items[1].Click += CopyPass_Click;
            passwordContextMenuStrip.Items[2].Click += Website_Click;
            passwordContextMenuStrip.Items[3].Click += ShowPassword_Click;
            passwordContextMenuStrip.Items[4].Click += EditButton_Click;
            passwordContextMenuStrip.Items[5].Click += DeleteButton_Click;
            #endregion

            userStatusLabel.Text = "Not logged in.";
        }
예제 #18
0
        /// <summary>
        /// Creates the change password view.
        /// </summary>
        /// <param name="changePasswordView">The change password view.</param>
        /// <param name="processingMessage">The processing message.</param>
        /// <returns></returns>
        public IChangePasswordView CreateChangePasswordView(IChangePasswordView changePasswordView, string processingMessage)
        {
            changePasswordView.ProcessingMessage = processingMessage;

            return(changePasswordView);
        }
예제 #19
0
        public ForgottenPasswordViewmodel(IView view, string emailAdress, bool changePassword = false)
        {
            ApiCallNotifier      = new NotifyTaskCompletion <object>(Task.FromResult <object>(null));
            _changePassword      = changePassword;
            _view                = view;
            EmailAdress          = emailAdress;
            SendEmailCodeCommand = new RelayCommand((object obj) =>
            {
                if (!string.IsNullOrWhiteSpace(EmailAdress))
                {
                    ApiCallNotifier = new NotifyTaskCompletion <object>(LoginRepository.Instance.SendPasswordResetCode(EmailAdress, _changePassword).ContinueWith(t => (object)t.Result), SendResetCodeCompleted);
                }
            });

            ConfirmCommand = new RelayCommand((object obj) =>
            {
                IChangePasswordView forgotView = (IChangePasswordView)obj;
                ErrorMessage = string.Empty;
                if (string.IsNullOrWhiteSpace(forgotView.PassBoxReg1.Password))
                {
                    ErrorMessage += "Geen wachwoord ingevuld";
                }
                if (forgotView.PassBoxReg1.Password != forgotView.PassBoxReg2.Password)
                {
                    if (ErrorMessage != string.Empty)
                    {
                        ErrorMessage += Environment.NewLine;
                    }
                    ErrorMessage += "Wachtwoorden komen niet overeen";
                }
                if (string.IsNullOrWhiteSpace(EmailAdress))
                {
                    if (ErrorMessage != string.Empty)
                    {
                        ErrorMessage += Environment.NewLine;
                    }
                    ErrorMessage += "Geen emailadres ingevuld";
                }
                if (string.IsNullOrWhiteSpace(ResetCode))
                {
                    if (ErrorMessage != string.Empty)
                    {
                        ErrorMessage += Environment.NewLine;
                    }
                    ErrorMessage += "Geen code ingevuld";
                }
                if (string.IsNullOrWhiteSpace(ErrorMessage))
                {
                    ApiCallNotifier = new NotifyTaskCompletion <object>(LoginRepository.Instance.ResetPasswordAsync(EmailAdress, ResetCode, forgotView.PassBoxReg1.Password).ContinueWith(t => (object)t.Result), async(object sender, EventArgs e) => await ResetPasswordCompletedAsync(sender, e));
                }
            });

            BackCommand = new RelayCommand(async(object obj) =>
            {
                if (!_changePassword)
                {
                    LoginView loginView   = new LoginView();
                    loginView.DataContext = new LoginViewmodel(loginView)
                    {
                        EmailAdress = EmailAdress
                    };
                    loginView.Show();
                    view.Close();
                }
                else
                {
                    view.Close();
                    await ChildWindowManager.ShowChildWindowAsync(MainWindow.CurrentMainWindow, new AccountView()
                    {
                        IsModal = true
                    });
                }
            });
        }