private void ChangeButtonClick(object sender, RoutedEventArgs e)
 {
     var context = DataContext as ChangePasswordViewModel;
     if (context != null)
     {
         var args = new ChangePasswordArgs(old, @new, new2);
         if (context.SaveCommand != null && context.SaveCommand.CanExecute(args))
         {
             context.SaveCommand.Execute(args);
         }
     }
 }
        private async void Save(ChangePasswordArgs args)
        {
            ErrorMessage = null;

            if (IsFormValid(args))
            {
                IsBusy = true;
                var task = await usersRepository.ChangePasswordAsync(userName, args.Old.Password, args.New.Password);
                IsBusy = false;
                if (task.Succeed)
                {
                    Confirmed = true;
                    Close();
                }
                else
                {
                    ErrorMessage = task.ErrorMessage;
                }
            }
        }
        private bool IsFormValid(ChangePasswordArgs args)
        {
            if (string.IsNullOrWhiteSpace(args.Old.Password))
            {
                ErrorMessage = "введите старый пароль";
                return false;
            }

            if (string.IsNullOrWhiteSpace(args.New.Password))
            {
                ErrorMessage = "введите новый пароль";
                return false;
            }

            var errors = Validate.Password(args.New.Password, args.New2.Password).ToArray();
            if (errors.Length > 0)
            {
                ErrorMessage = errors[0];
                return false;
            }

            return true;
        }