Exemplo n.º 1
0
 public void EditUser()
 {
     if (HashingHelper.HashPassword(_view.PasswordEditUser).Equals(GetCurrentUser().Password))
     {
         if (_view.Username.Length > 6)
         {
             if (_view.SelectedLocationTK != null)
             {
                 if (MessageBox.Show("You are about to change your personal data.\nAre you sure", "Change of data", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes)
                 {
                     User user   = new User(GetCurrentUser().Id, _view.Username, GetCurrentUser().Password, _view.Name, _view.Surname, _view.SelectedLocationTK, _view.Email, _view.Telephone);
                     bool result = _repository.EditUser(user);
                     Logout();
                     ReLog(user);
                     LoadFields();
                 }
             }
             else
             {
                 _view.WarningDialog = "Please select a location and a ZIP code";
             }
         }
         else
         {
             _view.WarningDialog = "Username is too small.\nMust use atleast 6 characters.";
         }
     }
     else
     {
         _view.WarningDialog = "Password is incorect.";
     }
 }
 public void UpdateUsersPassword(String newPass)
 {
     User user   = new User(GetCurrentUser().Id, GetCurrentUser().Username, HashingHelper.HashPassword(newPass), GetCurrentUser().Name, GetCurrentUser().Surname, GetCurrentUser().Address, GetCurrentUser().Email, GetCurrentUser().Telephone);
     bool result = _repository.EditUser(user);
 }