private void SaveButtonOnClick(object sender, RoutedEventArgs e) { if (NewPasswordTextEdit.Text == RepeatNewPasswordTextEdit.Text) { if (_activeUserId > 0) { using (var dbContext = new FarnahadManufacturingDbContext()) { var user = dbContext.Users.Find(_activeUserId); var password = EncryptionUtility.EncryptPassword(CurrentPasswordTextEdit.Text, user.PasswordSalt); if (user.Password == password) { ApplicationDataStore.SendData("CurrentPassword", password); ApplicationDataStore.SendData("CurrentPasswordSalt", user.PasswordSalt); CloseWindow(); } else { MessageBox.Show("رمز عبور اشتباه است."); } } } else { var passwordSalt = Guid.NewGuid().ToString(); var password = EncryptionUtility.EncryptPassword(NewPasswordTextEdit.Text, passwordSalt); ApplicationDataStore.SendData("CurrentPassword", password); ApplicationDataStore.SendData("CurrentPasswordSalt", passwordSalt); } } else { MessageBox.Show("رمز عبور غیر یکسان است."); } }