сброс пароля
This commit is contained in:
parent
4fc7c24c81
commit
11cb574c3a
@ -10,6 +10,7 @@ using ModuleTools.BusinessLogics;
|
||||
using ModuleTools.Extensions;
|
||||
using SecurityBusinessLogic.BindingModels;
|
||||
using SecurityBusinessLogic.BusinessLogics;
|
||||
using SecurityBusinessLogic.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
@ -36,7 +37,8 @@ namespace DepartmentWindowsDesktop.EntityControls
|
||||
{
|
||||
ControlOnMoveElem = new Dictionary<string, (string Title, EventHandler Event)>
|
||||
{
|
||||
{ "ToolStripMenuItemAddUser", ("Добавить пользователя", (object sender, EventArgs e) => { AddUser(); }) }
|
||||
{ "ToolStripMenuItemAddUser", ("Добавить пользователя", (object sender, EventArgs e) => { AddUser(); }) },
|
||||
{ "ToolStripMenuItemPasswordReset", ("Сброс пароля пользователя", (object sender, EventArgs e) => { PasswordReset(); }) }
|
||||
}
|
||||
};
|
||||
|
||||
@ -85,5 +87,35 @@ namespace DepartmentWindowsDesktop.EntityControls
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Сброс пароля пользователя
|
||||
/// </summary>
|
||||
private void PasswordReset()
|
||||
{
|
||||
if (_element == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var model = new EmployeeSetBindingModel();
|
||||
if (FillModel(model))
|
||||
{
|
||||
var logic = DependencyManager.Instance.Resolve<UserBusinessLogic>();
|
||||
var user = logic.GetElement(new UserGetBindingModel { Id = _element.UserId });
|
||||
if (user == null)
|
||||
{
|
||||
DialogHelper.MessageException(logic.Errors, "Ошибка при получении пользователя");
|
||||
return;
|
||||
}
|
||||
user.Password = model.DateBirth.ToShortDateString();
|
||||
user = logic.Update(Mapper.MapToClass<UserViewModel, UserSetBindingModel>(user, true));
|
||||
if (user == null)
|
||||
{
|
||||
DialogHelper.MessageException(logic.Errors, "Ошибка при получении пользователя");
|
||||
return;
|
||||
}
|
||||
DialogHelper.MessageInformation("Пароль сброшен", "Успех");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -10,6 +10,7 @@ using ModuleTools.BusinessLogics;
|
||||
using ModuleTools.Extensions;
|
||||
using SecurityBusinessLogic.BindingModels;
|
||||
using SecurityBusinessLogic.BusinessLogics;
|
||||
using SecurityBusinessLogic.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
@ -33,7 +34,8 @@ namespace DepartmentWindowsDesktop.EntityControls
|
||||
{
|
||||
ControlOnMoveElem = new Dictionary<string, (string Title, EventHandler Event)>
|
||||
{
|
||||
{ "ToolStripMenuItemAddUser", ("Добавить пользователя", (object sender, EventArgs e) => { AddUser(); }) }
|
||||
{ "ToolStripMenuItemAddUser", ("Добавить пользователя", (object sender, EventArgs e) => { AddUser(); }) },
|
||||
{ "ToolStripMenuItemPasswordReset", ("Сброс пароля пользователя", (object sender, EventArgs e) => { PasswordReset(); }) }
|
||||
}
|
||||
};
|
||||
|
||||
@ -82,5 +84,35 @@ namespace DepartmentWindowsDesktop.EntityControls
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Сброс пароля пользователя
|
||||
/// </summary>
|
||||
private void PasswordReset()
|
||||
{
|
||||
if (_element == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var model = new LecturerSetBindingModel();
|
||||
if (FillModel(model))
|
||||
{
|
||||
var logic = DependencyManager.Instance.Resolve<UserBusinessLogic>();
|
||||
var user = logic.GetElement(new UserGetBindingModel { Id = _element.UserId });
|
||||
if (user == null)
|
||||
{
|
||||
DialogHelper.MessageException(logic.Errors, "Ошибка при получении пользователя");
|
||||
return;
|
||||
}
|
||||
user.Password = model.DateBirth.ToShortDateString();
|
||||
user = logic.Update(Mapper.MapToClass<UserViewModel, UserSetBindingModel>(user, true));
|
||||
if (user == null)
|
||||
{
|
||||
DialogHelper.MessageException(logic.Errors, "Ошибка при получении пользователя");
|
||||
return;
|
||||
}
|
||||
DialogHelper.MessageInformation("Пароль сброшен", "Успех");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user