рефакторинг

This commit is contained in:
kotcheshir73 2021-04-03 16:21:16 +04:00
parent 9d68f31846
commit ecee1a9eeb
7 changed files with 19 additions and 14 deletions

View File

@ -15,18 +15,18 @@ namespace DatabaseCore.Models.Security
[EntityDependency("Role", "RoleId", "Доступные дейсвтиия создаются под конкретную роль")] [EntityDependency("Role", "RoleId", "Доступные дейсвтиия создаются под конкретную роль")]
public class Access : BaseEntity, IEntitySecurityExtenstion<Access> public class Access : BaseEntity, IEntitySecurityExtenstion<Access>
{ {
[Required]
[DataMember] [DataMember]
[Required]
[MapConfiguration("RoleId")] [MapConfiguration("RoleId")]
public Guid RoleId { get; set; } public Guid RoleId { get; set; }
[Required]
[DataMember] [DataMember]
[Required]
[MapConfiguration("AccessOperation")] [MapConfiguration("AccessOperation")]
public AccessOperation AccessOperation { get; set; } public AccessOperation AccessOperation { get; set; }
[Required]
[DataMember] [DataMember]
[Required]
[MapConfiguration("AccessType")] [MapConfiguration("AccessType")]
public AccessType AccessType { get; set; } public AccessType AccessType { get; set; }

View File

@ -13,13 +13,13 @@ namespace DatabaseCore.Models.Security
public class EnviromentSetting : IdEntity, IEntitySecurityExtenstion<EnviromentSetting> public class EnviromentSetting : IdEntity, IEntitySecurityExtenstion<EnviromentSetting>
{ {
[DataMember] [DataMember]
[MapConfiguration("Key")]
[Required] [Required]
[MapConfiguration("Key")]
public string Key { get; set; } public string Key { get; set; }
[DataMember] [DataMember]
[MapConfiguration("Value")]
[Required] [Required]
[MapConfiguration("Value")]
public string Value { get; set; } public string Value { get; set; }
[DataMember] [DataMember]

View File

@ -1,6 +1,7 @@
using ModuleTools.Attributes; using ModuleTools.Attributes;
using ModuleTools.Interfaces; using ModuleTools.Interfaces;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using System.Runtime.Serialization; using System.Runtime.Serialization;
@ -14,6 +15,7 @@ namespace DatabaseCore.Models.Security
public class Role : BaseEntity, IEntitySecurityExtenstion<Role> public class Role : BaseEntity, IEntitySecurityExtenstion<Role>
{ {
[DataMember] [DataMember]
[Required]
[MapConfiguration("RoleName")] [MapConfiguration("RoleName")]
public string RoleName { get; set; } public string RoleName { get; set; }

View File

@ -2,6 +2,7 @@
using ModuleTools.Interfaces; using ModuleTools.Interfaces;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using System.Runtime.Serialization; using System.Runtime.Serialization;
@ -15,10 +16,12 @@ namespace DatabaseCore.Models.Security
public class User : BaseEntity, IEntitySecurityExtenstion<User> public class User : BaseEntity, IEntitySecurityExtenstion<User>
{ {
[DataMember] [DataMember]
[Required]
[MapConfiguration("Login")] [MapConfiguration("Login")]
public string UserName { get; set; } public string UserName { get; set; }
[DataMember] [DataMember]
[Required]
[MapConfiguration("Password")] [MapConfiguration("Password")]
public string PasswordHash { get; set; } public string PasswordHash { get; set; }

View File

@ -16,23 +16,23 @@ namespace SecurityBusinessLogic.ViewModels
[ViewModelControlElementClass()] [ViewModelControlElementClass()]
public class AccessViewModel : ElementViewModel public class AccessViewModel : ElementViewModel
{ {
[MapConfiguration("RoleId", AllowCopyWithoutRigth = false)]
[ViewModelControlElementProperty("Роль", ControlType.ControlGuid, MustHaveValue = true, ReadOnly = true, ControlTypeObject = "SecurityWindowsDesktop.EntityControls.ControlRoleList, SecurityWindowsDesktop")] [ViewModelControlElementProperty("Роль", ControlType.ControlGuid, MustHaveValue = true, ReadOnly = true, ControlTypeObject = "SecurityWindowsDesktop.EntityControls.ControlRoleList, SecurityWindowsDesktop")]
[MapConfiguration("RoleId", AllowCopyWithoutRigth = false)]
public Guid RoleId { get; set; } public Guid RoleId { get; set; }
[ViewModelControlListProperty("Роль", ColumnWidth = 100)] [ViewModelControlListProperty("Роль", ColumnWidth = 100)]
[MapConfiguration("Role.RoleName", IsDifficle = true, AllowCopyWithoutRigth = false)] [MapConfiguration("Role.RoleName", IsDifficle = true, AllowCopyWithoutRigth = false)]
public string RoleName { get; set; } public string RoleName { get; set; }
[MapConfiguration("AccessOperation", AllowCopyWithoutRigth = false)]
[ViewModelControlElementProperty("Операция", ControlType.ControlEnum, MustHaveValue = true)] [ViewModelControlElementProperty("Операция", ControlType.ControlEnum, MustHaveValue = true)]
[MapConfiguration("AccessOperation", AllowCopyWithoutRigth = false)]
public AccessOperation AccessOperation { get; set; } public AccessOperation AccessOperation { get; set; }
[ViewModelControlListProperty("Операция")] [ViewModelControlListProperty("Операция")]
public string AccessOperationTitle => AccessOperation.ToString("G"); public string AccessOperationTitle => AccessOperation.ToString("G");
[MapConfiguration("AccessType", AllowCopyWithoutRigth = false)]
[ViewModelControlElementProperty("Тип", ControlType.ControlEnum, MustHaveValue = true)] [ViewModelControlElementProperty("Тип", ControlType.ControlEnum, MustHaveValue = true)]
[MapConfiguration("AccessType", AllowCopyWithoutRigth = false)]
public AccessType AccessType { get; set; } public AccessType AccessType { get; set; }
[ViewModelControlListProperty("Тип", ColumnWidth = 150)] [ViewModelControlListProperty("Тип", ColumnWidth = 150)]

View File

@ -16,16 +16,16 @@ namespace SecurityBusinessLogic.ViewModels
[ViewModelControlElementClass()] [ViewModelControlElementClass()]
public class UserRoleViewModel : ElementViewModel public class UserRoleViewModel : ElementViewModel
{ {
[MapConfiguration("UserId", AllowCopyWithoutRigth = false)]
[ViewModelControlElementProperty("Пользователь", ControlType.ControlGuid, MustHaveValue = true, ReadOnly = false, ControlTypeObject = "SecurityWindowsDesktop.EntityControls.ControlUserList, SecurityWindowsDesktop")] [ViewModelControlElementProperty("Пользователь", ControlType.ControlGuid, MustHaveValue = true, ReadOnly = false, ControlTypeObject = "SecurityWindowsDesktop.EntityControls.ControlUserList, SecurityWindowsDesktop")]
[MapConfiguration("UserId", AllowCopyWithoutRigth = false)]
public Guid UserId { get; set; } public Guid UserId { get; set; }
[ViewModelControlListProperty("Пользователь")] [ViewModelControlListProperty("Пользователь")]
[MapConfiguration("User.UserName", IsDifficle = true, AllowCopyWithoutRigth = false)] [MapConfiguration("User.UserName", IsDifficle = true, AllowCopyWithoutRigth = false)]
public string UserName { get; set; } public string UserName { get; set; }
[MapConfiguration("RoleId", AllowCopyWithoutRigth = false)]
[ViewModelControlElementProperty("Роль", ControlType.ControlGuid, MustHaveValue = true, ReadOnly = false, ControlTypeObject = "SecurityWindowsDesktop.EntityControls.ControlRoleList, SecurityWindowsDesktop")] [ViewModelControlElementProperty("Роль", ControlType.ControlGuid, MustHaveValue = true, ReadOnly = false, ControlTypeObject = "SecurityWindowsDesktop.EntityControls.ControlRoleList, SecurityWindowsDesktop")]
[MapConfiguration("RoleId", AllowCopyWithoutRigth = false)]
public Guid RoleId { get; set; } public Guid RoleId { get; set; }
[ViewModelControlListProperty("Роль")] [ViewModelControlListProperty("Роль")]

View File

@ -26,30 +26,30 @@ namespace SecurityBusinessLogic.ViewModels
[MapConfiguration("PasswordHash", AllowCopyWithoutRigth = false)] [MapConfiguration("PasswordHash", AllowCopyWithoutRigth = false)]
public string Password { get; set; } public string Password { get; set; }
[MapConfiguration("Avatar")]
[ViewModelControlElementProperty("Фото", ControlType.ControlImage, Width = 200, Height = 200)] [ViewModelControlElementProperty("Фото", ControlType.ControlImage, Width = 200, Height = 200)]
[MapConfiguration("Avatar")]
public byte[] Avatar { get; set; } public byte[] Avatar { get; set; }
[ViewModelControlListProperty("Посл. визит", ColumnWidth = 100, DefaultCellStyleFormat = "dd.MM.yyyy")] [ViewModelControlListProperty("Посл. визит", ColumnWidth = 100, DefaultCellStyleFormat = "dd.MM.yyyy")]
[MapConfiguration("DateLastVisit")] [MapConfiguration("DateLastVisit")]
public DateTime? DateLastVisit { get; set; } public DateTime? DateLastVisit { get; set; }
[MapConfiguration("IsBanned", AllowCopyWithoutRigth = false)]
[ViewModelControlElementProperty("Заблокирован", ControlType.ControlBool, MustHaveValue = true)] [ViewModelControlElementProperty("Заблокирован", ControlType.ControlBool, MustHaveValue = true)]
[MapConfiguration("IsBanned", AllowCopyWithoutRigth = false)]
public bool IsBanned { get; set; } public bool IsBanned { get; set; }
[ViewModelControlListProperty("Блокир.", ColumnWidth = 80)] [ViewModelControlListProperty("Блокир.", ColumnWidth = 80)]
public string Banned => IsBanned ? "Да" : "Нет"; public string Banned => IsBanned ? "Да" : "Нет";
[MapConfiguration("DateBanned", AllowCopyWithoutRigth = false)]
[ViewModelControlElementProperty("Дата блокировки", ControlType.ControlDateTime, ReadOnly = true)] [ViewModelControlElementProperty("Дата блокировки", ControlType.ControlDateTime, ReadOnly = true)]
[MapConfiguration("DateBanned", AllowCopyWithoutRigth = false)]
public DateTime? DateBanned { get; set; } public DateTime? DateBanned { get; set; }
[ViewModelControlListProperty("Дата Б.", ColumnWidth = 100)] [ViewModelControlListProperty("Дата Б.", ColumnWidth = 100)]
public string DateBannedTitle => DateBanned.HasValue ? DateBanned.Value.ToShortDateString() : string.Empty; public string DateBannedTitle => DateBanned.HasValue ? DateBanned.Value.ToShortDateString() : string.Empty;
[MapConfiguration("CountAttempt", AllowCopyWithoutRigth = false)]
[ViewModelControlElementProperty("Попытки входа", ControlType.ControlInt, ReadOnly = true)] [ViewModelControlElementProperty("Попытки входа", ControlType.ControlInt, ReadOnly = true)]
[MapConfiguration("CountAttempt", AllowCopyWithoutRigth = false)]
public int CountAttempt { get; set; } public int CountAttempt { get; set; }
public override string ToString() => Login; public override string ToString() => Login;