首次提交:添加src文件夹代码
This commit is contained in:
68
Cowain.Bake.UI/Home/ViewModels/ModifyPassWordViewModel.cs
Normal file
68
Cowain.Bake.UI/Home/ViewModels/ModifyPassWordViewModel.cs
Normal file
@@ -0,0 +1,68 @@
|
||||
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);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user