DepartmentProject/DepartmentPortal/Security/SecurityBusinessLogic/ViewModels/UserViewModels.cs

53 lines
2.3 KiB
C#
Raw Normal View History

using CoreModels.ModelsSecurity;
using ModuleTools.Attributes;
2021-03-30 22:34:31 +04:00
using ModuleTools.Enums;
using ModuleTools.ViewModels;
using System;
namespace SecurityBusinessLogic.ViewModels
{
/// <summary>
/// Список пользователей
/// </summary>
public class UserListViewModel : ListViewModel<UserViewModel> { }
/// <summary>
/// Элемент пользователей
/// </summary>
[ViewModelControlElementClass(HaveDependenceEntities = true, Width = 800, Height = 400)]
[ViewModelControlElementDependenceEntity(Title = "Роли", Order = 1, ParentPropertyName = "UserId",
ControlTypeObject = "SecurityWindowsDesktop.EntityControls.ControlUserRoleList, SecurityWindowsDesktop")]
public class UserViewModel : ElementViewModel, IUserModel
{
[ViewModelControlListProperty("Пользователь")]
[ViewModelControlElementProperty("Логин", ControlType.ControlString, MustHaveValue = true)]
public string UserName { get; set; }
[MapConfiguration("PasswordHash", AllowCopyWithoutRigth = false)]
public string PasswordHash { get; set; }
[ViewModelControlElementProperty("Фото", ControlType.ControlImage, Width = 200, Height = 200)]
public byte[] Avatar { get; set; }
[ViewModelControlListProperty("Посл. визит", ColumnWidth = 100, DefaultCellStyleFormat = "dd.MM.yyyy")]
public DateTime? DateLastVisit { get; set; }
[ViewModelControlElementProperty("Заблокирован", ControlType.ControlBool, MustHaveValue = true)]
2021-04-03 16:21:16 +04:00
[MapConfiguration("IsBanned", AllowCopyWithoutRigth = false)]
public bool IsBanned { get; set; }
[ViewModelControlListProperty("Блокир.", ColumnWidth = 80)]
public string Banned => IsBanned ? "Да" : "Нет";
[ViewModelControlElementProperty("Дата блокировки", ControlType.ControlDateTime, ReadOnly = true)]
2021-04-03 16:21:16 +04:00
[MapConfiguration("DateBanned", AllowCopyWithoutRigth = false)]
public DateTime? DateBanned { get; set; }
[ViewModelControlListProperty("Дата Б.", ColumnWidth = 100)]
public string DateBannedTitle => DateBanned.HasValue ? DateBanned.Value.ToShortDateString() : string.Empty;
[ViewModelControlElementProperty("Попытки входа", ControlType.ControlInt, ReadOnly = true)]
2021-04-03 16:21:16 +04:00
[MapConfiguration("CountAttempt", AllowCopyWithoutRigth = false)]
public int CountAttempt { get; set; }
}
}