| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 | 
							- using InABox.Clients;
 
- using InABox.Configuration;
 
- using InABox.Core;
 
- using InABox.Wpf;
 
- using System;
 
- using System.Collections.Generic;
 
- using System.Linq;
 
- using System.Text;
 
- using System.Threading.Tasks;
 
- using System.Windows;
 
- using System.Windows.Controls;
 
- using System.Windows.Data;
 
- using System.Windows.Documents;
 
- using System.Windows.Input;
 
- using System.Windows.Media;
 
- using System.Windows.Media.Imaging;
 
- using System.Windows.Shapes;
 
- namespace PRSDesktop.Forms
 
- {
 
-     /// <summary>
 
-     /// Interaction logic for ChangePassword.xaml
 
-     /// </summary>
 
-     public partial class ChangePassword : ThemableWindow
 
-     {
 
-         private Guid UserGuid { get; set; }
 
-         public string? Password { get; set; }
 
-         public ChangePassword(Guid userGuid)
 
-         {
 
-             InitializeComponent();
 
-             UserGuid = userGuid;
 
-         }
 
-         private void SetError(string message)
 
-         {
 
-             Error.Content = message;
 
-         }
 
-         public static void ChangeUserPassword(User user, string password)
 
-         {
 
-             user.Password = password;
 
-         }
 
-         private void ChangePassword_Click(object sender, RoutedEventArgs e)
 
-         {
 
-             var newPassword = NewPassword.Password;
 
-             if (string.IsNullOrWhiteSpace(newPassword))
 
-             {
 
-                 MessageBox.Show("Please enter a new password.");
 
-                 return;
 
-             }
 
-             else if(newPassword != ConfirmPassword.Password)
 
-             {
 
-                 MessageBox.Show("The confirmed password does not match the new password!");
 
-                 NewPassword.Clear();
 
-                 ConfirmPassword.Clear();
 
-                 return;
 
-             }
 
-             var user = new Client<User>().Query(
 
-                 new Filter<User>(x => x.ID).IsEqualTo(UserGuid)
 
-                     .And(x => x.Password).IsEqualTo(CurrentPassword.Password),
 
-                 Columns.None<User>().Add(x => x.ID)).Rows.FirstOrDefault();
 
-             if(user == null)
 
-             {
 
-                 MessageBox.Show("The current password is incorrect!");
 
-                 CurrentPassword.Clear();
 
-                 return;
 
-             }
 
-             else if(newPassword == CurrentPassword.Password)
 
-             {
 
-                 MessageBox.Show("The new password cannot be the same as the old one!");
 
-                 NewPassword.Clear();
 
-                 ConfirmPassword.Clear();
 
-                 return;
 
-             }
 
-             Password = newPassword;
 
-             DialogResult = true;
 
-             Close();
 
-         }
 
-         private void Cancel_Click(object sender, RoutedEventArgs e)
 
-         {
 
-             DialogResult = false;
 
-             Close();
 
-         }
 
-     }
 
- }
 
 
  |