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

55 lines
2.1 KiB
C#
Raw Normal View History

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>
public class UserViewModel : ElementViewModel
{
[ViewModelOnListProperty("Пользователь")]
2021-03-30 22:34:31 +04:00
[ViewModelOnElementProperty("Логин", ControlType.ControlString, MustHaveValue = true)]
[MapConfiguration("UserName")]
public string Login { get; set; }
[MapConfiguration("PasswordHash", AllowCopyWithoutRigth = false)]
public string Password { get; set; }
[MapConfiguration("Avatar")]
2021-03-30 22:34:31 +04:00
[ViewModelOnElementProperty("Фото", ControlType.ControlImage, 200, 200)]
public byte[] Avatar { get; set; }
[ViewModelOnListProperty("Посл. визит", 100)]
[MapConfiguration("DateLastVisit")]
public DateTime? DateLastVisit { get; set; }
[MapConfiguration("IsBanned", AllowCopyWithoutRigth = false)]
2021-03-30 22:34:31 +04:00
[ViewModelOnElementProperty("Заблокирован", ControlType.ControlBool, MustHaveValue = true)]
public bool IsBanned { get; set; }
[ViewModelOnListProperty("Блокир.", 80)]
public string Banned => IsBanned ? "Да" : "Нет";
[MapConfiguration("DateBanned", AllowCopyWithoutRigth = false)]
2021-03-30 22:34:31 +04:00
[ViewModelOnElementProperty("Дата блокировки", ControlType.ControlDateTime, ReadOnly = true)]
public DateTime? DateBanned { get; set; }
[ViewModelOnListProperty("Дата Б.", 100)]
public string DateBannedTitle => DateBanned.HasValue ? DateBanned.Value.ToShortDateString() : string.Empty;
[MapConfiguration("CountAttempt", AllowCopyWithoutRigth = false)]
2021-03-30 22:34:31 +04:00
[ViewModelOnElementProperty("Попытки входа", ControlType.ControlInt , ReadOnly = true)]
public int CountAttempt { get; set; }
public override string ToString() => Login;
}
}