69 lines
2.0 KiB
C#
69 lines
2.0 KiB
C#
using Cowain.Bake.BLL;
|
|
using Cowain.Bake.Common.Core;
|
|
using Prism.Commands;
|
|
using Prism.Mvvm;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Unity;
|
|
|
|
namespace Cowain.Bake.UI.Home.ViewModels
|
|
{
|
|
public class ModifyPassWordViewModel : BindableBase
|
|
{
|
|
|
|
private string newPassWord;
|
|
public string NewPassWord
|
|
{
|
|
get => newPassWord;
|
|
set => SetProperty(ref newPassWord, value);
|
|
}
|
|
|
|
private string checkPassWord;
|
|
public string CheckPassWord
|
|
{
|
|
get => checkPassWord;
|
|
set => SetProperty(ref checkPassWord, value);
|
|
}
|
|
|
|
private string oldPassWord;
|
|
public string OldPassWord
|
|
{
|
|
get => oldPassWord;
|
|
set => SetProperty(ref oldPassWord, value);
|
|
}
|
|
|
|
IUnityContainer _unityContainer;
|
|
public ModifyPassWordViewModel(IUnityContainer unityContainer)
|
|
{
|
|
_unityContainer = unityContainer;
|
|
}
|
|
|
|
public DelegateCommand<object> ModifyCommand => new DelegateCommand<object>((x) =>
|
|
{
|
|
var memory = _unityContainer.Resolve<MemoryDataProvider>();
|
|
if (!_unityContainer.Resolve<UserService>().ValidPassword(memory.CurrentUser.UserId, OldPassWord))
|
|
{
|
|
HandyControl.Controls.MessageBox.Warning($"旧密码不正确,请重新输入!");
|
|
return;
|
|
}
|
|
|
|
if (NewPassWord != CheckPassWord)
|
|
{
|
|
HandyControl.Controls.MessageBox.Warning("新密码和验证密码不匹配,请重新输入!");
|
|
return;
|
|
}
|
|
|
|
if (0 == _unityContainer.Resolve<UserService>().ModifyPassword(NewPassWord))
|
|
{
|
|
HandyControl.Controls.MessageBox.Warning("修改密码失败!");
|
|
return;
|
|
}
|
|
|
|
LogHelper.Instance.Info($"用户:{memory.CurrentUser.UserId}, 修改密码成功!", true);
|
|
});
|
|
}
|
|
}
|