DepartmentProject/DepartmentPortal/Security/SecurityBusinessLogic/ViewModels/AccessViewModels.cs
kotcheshir73 e8836c8806 куча наработко по выводу элемента и списка
правки по сущностям безоапсности
2021-04-01 21:30:29 +04:00

50 lines
1.9 KiB
C#

using ModuleTools.Attributes;
using ModuleTools.Enums;
using ModuleTools.ViewModels;
using System;
namespace SecurityBusinessLogic.ViewModels
{
/// <summary>
/// Список достпуов
/// </summary>
public class AccessListViewModel : ListViewModel<AccessViewModel> { }
/// <summary>
/// Элемент доступа
/// </summary>
[ViewModelControlElementClass()]
public class AccessViewModel : ElementViewModel
{
[MapConfiguration("RoleId", AllowCopyWithoutRigth = false)]
[ViewModelControlElementProperty("Роль", ControlType.ControlGuid, MustHaveValue = true, ReadOnly = true, ControlTypeObject = "SecurityWindowsDesktop.Controls.ControlRoleList, SecurityWindowsDesktop")]
public Guid RoleId { get; set; }
[ViewModelControlListProperty("Роль", 100)]
[MapConfiguration("Role.RoleName", IsDifficle = true, AllowCopyWithoutRigth = false)]
public string RoleName { get; set; }
[MapConfiguration("AccessOperation", AllowCopyWithoutRigth = false)]
[ViewModelControlElementProperty("Операция", ControlType.ControlEnum, MustHaveValue = true)]
public AccessOperation AccessOperation { get; set; }
[ViewModelControlListProperty("Операция")]
public string AccessOperationTitle => AccessOperation.ToString("G");
[MapConfiguration("AccessType", AllowCopyWithoutRigth = false)]
[ViewModelControlElementProperty("Тип", ControlType.ControlEnum, MustHaveValue = true)]
public AccessType AccessType { get; set; }
[ViewModelControlListProperty("Тип", 150)]
public string AccessTypeTitle => AccessType switch
{
AccessType.Delete => "Полные права",
AccessType.Change => "Просмотр, Редактирование",
AccessType.View => "Просмотр",
_ => "Неопределено",
};
public override string ToString() => $"{RoleName}-{AccessOperationTitle}({AccessTypeTitle})";
}
}