diff --git a/DepartmentPortal/Common/CoreModels/CoreModels.csproj b/DepartmentPortal/Common/CoreModels/CoreModels.csproj new file mode 100644 index 0000000..9deb5b3 --- /dev/null +++ b/DepartmentPortal/Common/CoreModels/CoreModels.csproj @@ -0,0 +1,11 @@ + + + + net5.0 + + + + + + + diff --git a/DepartmentPortal/Common/CoreModels/ModelsSecurity/IAccessModel.cs b/DepartmentPortal/Common/CoreModels/ModelsSecurity/IAccessModel.cs new file mode 100644 index 0000000..920cd4c --- /dev/null +++ b/DepartmentPortal/Common/CoreModels/ModelsSecurity/IAccessModel.cs @@ -0,0 +1,27 @@ +using CoreModels.Tools; +using ModuleTools.Attributes; +using ModuleTools.Enums; +using System; + +namespace CoreModels.ModelsSecurity +{ + [EntityDescription("Access", "Доступные действия для ролей")] + [EntityDependency("Role", "RoleId", "Доступные дейсвтиия создаются под конкретную роль")] + public interface IAccessModel : IId + { + /// + /// Илентификатор роли + /// + Guid RoleId { get; } + + /// + /// Тип операции + /// + AccessOperation AccessOperation { get; } + + /// + /// Режим доступа + /// + AccessType AccessType { get; } + } +} \ No newline at end of file diff --git a/DepartmentPortal/Common/CoreModels/ModelsSecurity/IEnviromentSettingModel.cs b/DepartmentPortal/Common/CoreModels/ModelsSecurity/IEnviromentSettingModel.cs new file mode 100644 index 0000000..c50de10 --- /dev/null +++ b/DepartmentPortal/Common/CoreModels/ModelsSecurity/IEnviromentSettingModel.cs @@ -0,0 +1,27 @@ +using CoreModels.Tools; +using ModuleTools.Attributes; + +namespace CoreModels.ModelsSecurity +{ + /// + /// Модель, описывающиая общие настройки системы + /// + [EntityDescription("EnviromentSetting", "Общие настройки системы")] + public interface IEnviromentSettingModel : IId + { + /// + /// Ключ настройки + /// + string Key { get; } + + /// + /// Значение настройки + /// + string Value { get; } + + /// + /// Описание настройки + /// + string Description { get; } + } +} \ No newline at end of file diff --git a/DepartmentPortal/Common/CoreModels/ModelsSecurity/IRoleModel.cs b/DepartmentPortal/Common/CoreModels/ModelsSecurity/IRoleModel.cs new file mode 100644 index 0000000..f57a461 --- /dev/null +++ b/DepartmentPortal/Common/CoreModels/ModelsSecurity/IRoleModel.cs @@ -0,0 +1,16 @@ +using CoreModels.Tools; +using ModuleTools.Attributes; + +namespace CoreModels.ModelsSecurity +{ + /// + /// Модель, описывающиая роль в системе + /// + [EntityDescription("Role", "Роли в системе")] + public interface IRoleModel : IId + { + string RoleName { get; } + + int RolePriority { get; } + } +} \ No newline at end of file diff --git a/DepartmentPortal/Common/CoreModels/ModelsSecurity/IUserModel.cs b/DepartmentPortal/Common/CoreModels/ModelsSecurity/IUserModel.cs new file mode 100644 index 0000000..97e92a7 --- /dev/null +++ b/DepartmentPortal/Common/CoreModels/ModelsSecurity/IUserModel.cs @@ -0,0 +1,27 @@ +using CoreModels.Tools; +using ModuleTools.Attributes; +using System; + +namespace CoreModels.ModelsSecurity +{ + /// + /// Модель, описывающиая пользователя системы + /// + [EntityDescription("User", "Пользователи системы")] + public interface IUserModel : IId + { + string UserName { get; } + + string PasswordHash { get; } + + byte[] Avatar { get; } + + DateTime? DateLastVisit { get; } + + bool IsBanned { get; } + + DateTime? DateBanned { get; } + + int CountAttempt { get; } + } +} \ No newline at end of file diff --git a/DepartmentPortal/Common/CoreModels/ModelsSecurity/IUserRoleModel.cs b/DepartmentPortal/Common/CoreModels/ModelsSecurity/IUserRoleModel.cs new file mode 100644 index 0000000..21d0f4f --- /dev/null +++ b/DepartmentPortal/Common/CoreModels/ModelsSecurity/IUserRoleModel.cs @@ -0,0 +1,19 @@ +using CoreModels.Tools; +using ModuleTools.Attributes; +using System; + +namespace CoreModels.ModelsSecurity +{ + /// + /// Связка пользователь - роль + /// + [EntityDescription("UserRole", "Связь пользователей системы с ролями, которые им назначены")] + [EntityDependency("Role", "RoleId", "К какой роли относится пользователь")] + [EntityDependency("User", "UserId", "К какой роли относится пользователь")] + public interface IUserRoleModel : IId + { + Guid RoleId { get; } + + Guid UserId { get; } + } +} \ No newline at end of file diff --git a/DepartmentPortal/Common/CoreModels/Tools/IId.cs b/DepartmentPortal/Common/CoreModels/Tools/IId.cs new file mode 100644 index 0000000..cf4135d --- /dev/null +++ b/DepartmentPortal/Common/CoreModels/Tools/IId.cs @@ -0,0 +1,9 @@ +using System; + +namespace CoreModels.Tools +{ + public interface IId + { + Guid Id { get; } + } +} \ No newline at end of file diff --git a/DepartmentPortal/Common/DatabaseCore/DatabaseCore.csproj b/DepartmentPortal/Common/DatabaseCore/DatabaseCore.csproj index b72d084..ed38e53 100644 --- a/DepartmentPortal/Common/DatabaseCore/DatabaseCore.csproj +++ b/DepartmentPortal/Common/DatabaseCore/DatabaseCore.csproj @@ -14,6 +14,7 @@ + diff --git a/DepartmentPortal/Common/DatabaseCore/Models/Security/Access.cs b/DepartmentPortal/Common/DatabaseCore/Models/Security/Access.cs index 58c1ba2..256087c 100644 --- a/DepartmentPortal/Common/DatabaseCore/Models/Security/Access.cs +++ b/DepartmentPortal/Common/DatabaseCore/Models/Security/Access.cs @@ -1,4 +1,5 @@ -using ModuleTools.Attributes; +using CoreModels.ModelsSecurity; +using ModuleTools.Attributes; using ModuleTools.Enums; using ModuleTools.Interfaces; using System; @@ -7,13 +8,8 @@ using System.Runtime.Serialization; namespace DatabaseCore.Models.Security { - /// - /// Класс, описывающий возможные действия для роли - /// - [DataContract] - [EntityDescription("Access", "Доступные действия для ролей")] - [EntityDependency("Role", "RoleId", "Доступные дейсвтиия создаются под конкретную роль")] - public class Access : BaseEntity, IEntitySecurityExtenstion + [DataContract] + public class Access : BaseEntity, IEntitySecurityExtenstion, IAccessModel { [DataMember] [Required] @@ -47,6 +43,6 @@ namespace DatabaseCore.Models.Security return entity; } - public override string ToString() => $"{Role.RoleName}-{AccessOperation.ToString("G")}({AccessType.ToString("G")})"; + public override string ToString() => $"{Role.RoleName}-{AccessOperation:G}({AccessType:G})"; } } \ No newline at end of file diff --git a/DepartmentPortal/Common/DatabaseCore/Models/Security/EnviromentSetting.cs b/DepartmentPortal/Common/DatabaseCore/Models/Security/EnviromentSetting.cs index 9bc83a9..3079c67 100644 --- a/DepartmentPortal/Common/DatabaseCore/Models/Security/EnviromentSetting.cs +++ b/DepartmentPortal/Common/DatabaseCore/Models/Security/EnviromentSetting.cs @@ -1,16 +1,13 @@ -using ModuleTools.Attributes; +using CoreModels.ModelsSecurity; +using ModuleTools.Attributes; using ModuleTools.Interfaces; using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; namespace DatabaseCore.Models.Security { - /// - /// Класс, описывающий общие настройки системы - /// [DataContract] - [EntityDescription("EnviromentSetting", "Общие настройки системы")] - public class EnviromentSetting : BaseEntity, IEntitySecurityExtenstion + public class EnviromentSetting : BaseEntity, IEntitySecurityExtenstion, IEnviromentSettingModel { [DataMember] [Required] diff --git a/DepartmentPortal/Common/DatabaseCore/Models/Security/Role.cs b/DepartmentPortal/Common/DatabaseCore/Models/Security/Role.cs index 91080e2..4f08e25 100644 --- a/DepartmentPortal/Common/DatabaseCore/Models/Security/Role.cs +++ b/DepartmentPortal/Common/DatabaseCore/Models/Security/Role.cs @@ -1,4 +1,5 @@ -using ModuleTools.Attributes; +using CoreModels.ModelsSecurity; +using ModuleTools.Attributes; using ModuleTools.Interfaces; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; @@ -7,12 +8,8 @@ using System.Runtime.Serialization; namespace DatabaseCore.Models.Security { - /// - /// Класс, описывающий роль в системе - /// [DataContract] - [EntityDescription("Role", "Роли в системе")] - public class Role : BaseEntity, IEntitySecurityExtenstion + public class Role : BaseEntity, IEntitySecurityExtenstion, IRoleModel { [DataMember] [Required] diff --git a/DepartmentPortal/Common/DatabaseCore/Models/Security/User.cs b/DepartmentPortal/Common/DatabaseCore/Models/Security/User.cs index b201fa5..8e26bb3 100644 --- a/DepartmentPortal/Common/DatabaseCore/Models/Security/User.cs +++ b/DepartmentPortal/Common/DatabaseCore/Models/Security/User.cs @@ -1,4 +1,5 @@ -using DatabaseCore.Models.Department; +using CoreModels.ModelsSecurity; +using DatabaseCore.Models.Department; using ModuleTools.Attributes; using ModuleTools.Interfaces; using System; @@ -9,21 +10,17 @@ using System.Runtime.Serialization; namespace DatabaseCore.Models.Security { - /// - /// Класс, описывающий пользователя системы - /// [DataContract] - [EntityDescription("User", "Пользователи системы")] - public class User : BaseEntity, IEntitySecurityExtenstion + public class User : BaseEntity, IEntitySecurityExtenstion, IUserModel { [DataMember] [Required] - [MapConfiguration("Login")] + [MapConfiguration("UserName")] public string UserName { get; set; } [DataMember] [Required] - [MapConfiguration("Password")] + [MapConfiguration("PasswordHash")] public string PasswordHash { get; set; } [DataMember] diff --git a/DepartmentPortal/Common/DatabaseCore/Models/Security/UserRole.cs b/DepartmentPortal/Common/DatabaseCore/Models/Security/UserRole.cs index 8b6af97..5e41af3 100644 --- a/DepartmentPortal/Common/DatabaseCore/Models/Security/UserRole.cs +++ b/DepartmentPortal/Common/DatabaseCore/Models/Security/UserRole.cs @@ -1,18 +1,13 @@ -using ModuleTools.Attributes; +using CoreModels.ModelsSecurity; +using ModuleTools.Attributes; using ModuleTools.Interfaces; using System; using System.Runtime.Serialization; namespace DatabaseCore.Models.Security { - /// - /// Связка пользователь - роль - /// [DataContract] - [EntityDescription("UserRole", "Связь пользователей системы с ролями, которые им назначены")] - [EntityDependency("Role", "RoleId", "К какой роли относится пользователь")] - [EntityDependency("User", "UserId", "К какой роли относится пользователь")] - public class UserRole : BaseEntity, IEntitySecurityExtenstion + public class UserRole : BaseEntity, IEntitySecurityExtenstion, IUserRoleModel { [DataMember] [MapConfiguration("RoleId")] diff --git a/DepartmentPortal/Common/DatabaseCore/SecurityManager.cs b/DepartmentPortal/Common/DatabaseCore/SecurityManager.cs index 00d5eb1..a9e6799 100644 --- a/DepartmentPortal/Common/DatabaseCore/SecurityManager.cs +++ b/DepartmentPortal/Common/DatabaseCore/SecurityManager.cs @@ -11,7 +11,7 @@ using System.Threading.Tasks; namespace DatabaseCore { - public class SecurityManager : ISecurityManager + public class SecurityManager : ISecurityManager { private readonly int _countDayToBanned = 3; diff --git a/DepartmentPortal/Common/DesktopTools/Interfaces/IControl.cs b/DepartmentPortal/Common/DesktopTools/Interfaces/IControl.cs index c4da828..29b1c07 100644 --- a/DepartmentPortal/Common/DesktopTools/Interfaces/IControl.cs +++ b/DepartmentPortal/Common/DesktopTools/Interfaces/IControl.cs @@ -4,10 +4,10 @@ using System; namespace DesktopTools.Interfaces { - /// - /// Основные параметры для контрола - /// - public interface IControl + /// + /// Основные параметры для контрола + /// + public interface IControl { /// /// Идентификатор контрола diff --git a/DepartmentPortal/Common/DesktopTools/MainControls/MainControlViewEntityElement.cs b/DepartmentPortal/Common/DesktopTools/MainControls/MainControlViewEntityElement.cs index 1f2934b..62693c3 100644 --- a/DepartmentPortal/Common/DesktopTools/MainControls/MainControlViewEntityElement.cs +++ b/DepartmentPortal/Common/DesktopTools/MainControls/MainControlViewEntityElement.cs @@ -6,7 +6,7 @@ using System.Windows.Forms; namespace DesktopTools.Controls { - public partial class MainControlViewEntityElement : UserControl, IControl, IControlChildEntity + public partial class MainControlViewEntityElement : UserControl, IControl, IControlChildEntity { /// /// Методы для реализации в generic-контроле diff --git a/DepartmentPortal/Common/DesktopTools/MainControls/MainControlViewEntityList.cs b/DepartmentPortal/Common/DesktopTools/MainControls/MainControlViewEntityList.cs index 7527b78..3518d0e 100644 --- a/DepartmentPortal/Common/DesktopTools/MainControls/MainControlViewEntityList.cs +++ b/DepartmentPortal/Common/DesktopTools/MainControls/MainControlViewEntityList.cs @@ -6,7 +6,7 @@ using System.Windows.Forms; namespace DesktopTools.Controls { - public partial class MainControlViewEntityList : UserControl, IControl, IControlChildEntity, IControlEntityList, IControlEntitySelectable + public partial class MainControlViewEntityList : UserControl, IControl, IControlChildEntity, IControlEntityList, IControlEntitySelectable { /// /// Методы для реализации в generic-контроле diff --git a/DepartmentPortal/Common/ModuleTools/Attributes/EntityDependencyAttribute.cs b/DepartmentPortal/Common/ModuleTools/Attributes/EntityDependencyAttribute.cs index 0578d72..ad3cf9d 100644 --- a/DepartmentPortal/Common/ModuleTools/Attributes/EntityDependencyAttribute.cs +++ b/DepartmentPortal/Common/ModuleTools/Attributes/EntityDependencyAttribute.cs @@ -6,7 +6,7 @@ namespace ModuleTools.Attributes /// Оописание зависимости сущности от другой сущности (требуется для выстраивания последоватльности сохранения и загрузки данных, /// применяется к классам-описывающим сущности в хранилище) /// - [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] + [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = true)] public class EntityDependencyAttribute : Attribute { /// diff --git a/DepartmentPortal/Common/ModuleTools/Attributes/EntityDescriptionAttribute.cs b/DepartmentPortal/Common/ModuleTools/Attributes/EntityDescriptionAttribute.cs index 216294f..2e8259b 100644 --- a/DepartmentPortal/Common/ModuleTools/Attributes/EntityDescriptionAttribute.cs +++ b/DepartmentPortal/Common/ModuleTools/Attributes/EntityDescriptionAttribute.cs @@ -6,7 +6,7 @@ namespace ModuleTools.Attributes /// Оописание класса из базы данных, его назначение (требуется для выстраивания иерархии с описанием классов, /// применяется к классам-описывающим сущности в хранилище) /// - [AttributeUsage(AttributeTargets.Class)] + [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface)] public class EntityDescriptionAttribute : Attribute { /// diff --git a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Employee/ControlEmployeeElement.cs b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Employee/ControlEmployeeElement.cs index 772cde1..9c50368 100644 --- a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Employee/ControlEmployeeElement.cs +++ b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Employee/ControlEmployeeElement.cs @@ -68,8 +68,8 @@ namespace DepartmentWindowsDesktop.EntityControls { var newuser = logic.Create(new UserSetBindingModel { - Login = userName, - Password = model.DateBirth.ToShortDateString(), + UserName = userName, + PasswordHash = model.DateBirth.ToShortDateString(), Avatar = model.Photo }); if (newuser == null) @@ -107,7 +107,7 @@ namespace DepartmentWindowsDesktop.EntityControls DialogHelper.MessageException(logic.Errors, "Ошибка при получении пользователя"); return; } - user.Password = model.DateBirth.ToShortDateString(); + user.PasswordHash = model.DateBirth.ToShortDateString(); user = logic.Update(Mapper.MapToClass(user, true)); if (user == null) { diff --git a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Lecturer/ControlLecturerElement.cs b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Lecturer/ControlLecturerElement.cs index 069f0e3..3e9270d 100644 --- a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Lecturer/ControlLecturerElement.cs +++ b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Lecturer/ControlLecturerElement.cs @@ -68,8 +68,8 @@ namespace DepartmentWindowsDesktop.EntityControls { var newuser = logic.Create(new UserSetBindingModel { - Login = userName, - Password = model.DateBirth.ToShortDateString(), + UserName = userName, + PasswordHash = model.DateBirth.ToShortDateString(), Avatar = model.Photo }); if (newuser == null) @@ -107,7 +107,7 @@ namespace DepartmentWindowsDesktop.EntityControls DialogHelper.MessageException(logic.Errors, "Ошибка при получении пользователя"); return; } - user.Password = model.DateBirth.ToShortDateString(); + user.PasswordHash = model.DateBirth.ToShortDateString(); user = logic.Update(Mapper.MapToClass(user, true)); if (user == null) { diff --git a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Student/ControlStudentElement.cs b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Student/ControlStudentElement.cs index f982845..16bb4a1 100644 --- a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Student/ControlStudentElement.cs +++ b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/Student/ControlStudentElement.cs @@ -62,8 +62,8 @@ namespace DepartmentWindowsDesktop.EntityControls } user = logic.Create(new UserSetBindingModel { - Login = model.NumberOfBook, - Password = userName, + UserName = model.NumberOfBook, + PasswordHash = userName, Avatar = model.Photo }); if (user == null) @@ -100,7 +100,7 @@ namespace DepartmentWindowsDesktop.EntityControls DialogHelper.MessageException(logic.Errors, "Ошибка при получении пользователя"); return; } - user.Password = model.NumberOfBook; + user.PasswordHash = model.NumberOfBook; user = logic.Update(Mapper.MapToClass(user, true)); if (user == null) { diff --git a/DepartmentPortal/DepartmentPortal.sln b/DepartmentPortal/DepartmentPortal.sln index 8e646f0..3db6a90 100644 --- a/DepartmentPortal/DepartmentPortal.sln +++ b/DepartmentPortal/DepartmentPortal.sln @@ -23,11 +23,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ModuleTools", "Common\Modul EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Department", "Department", "{A19E7709-6AD8-4E9B-B3AB-4339C67D9F39}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DepartmentBusinessLogic", "Department\DepartmentBusinessLogic\DepartmentBusinessLogic.csproj", "{69B94DB1-D1BE-4905-81AC-A5D49D0C9719}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DepartmentBusinessLogic", "Department\DepartmentBusinessLogic\DepartmentBusinessLogic.csproj", "{69B94DB1-D1BE-4905-81AC-A5D49D0C9719}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DepartmentDatabaseImplementation", "Department\DepartmentDatabaseImplementation.csproj\DepartmentDatabaseImplementation.csproj", "{1A9E20FE-6324-4839-A3AD-5726305122A5}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DepartmentDatabaseImplementation", "Department\DepartmentDatabaseImplementation.csproj\DepartmentDatabaseImplementation.csproj", "{1A9E20FE-6324-4839-A3AD-5726305122A5}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DepartmentWindowsDesktop", "Department\DepartmentWindowsDesktop\DepartmentWindowsDesktop.csproj", "{8E12DE14-0D83-48D8-964D-8B2BB06DB129}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DepartmentWindowsDesktop", "Department\DepartmentWindowsDesktop\DepartmentWindowsDesktop.csproj", "{8E12DE14-0D83-48D8-964D-8B2BB06DB129}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CoreModels", "Common\CoreModels\CoreModels.csproj", "{FDF81413-ABAD-4890-A60F-4FEC62DD2A7D}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -75,6 +77,10 @@ Global {8E12DE14-0D83-48D8-964D-8B2BB06DB129}.Debug|Any CPU.Build.0 = Debug|Any CPU {8E12DE14-0D83-48D8-964D-8B2BB06DB129}.Release|Any CPU.ActiveCfg = Release|Any CPU {8E12DE14-0D83-48D8-964D-8B2BB06DB129}.Release|Any CPU.Build.0 = Release|Any CPU + {FDF81413-ABAD-4890-A60F-4FEC62DD2A7D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FDF81413-ABAD-4890-A60F-4FEC62DD2A7D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FDF81413-ABAD-4890-A60F-4FEC62DD2A7D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FDF81413-ABAD-4890-A60F-4FEC62DD2A7D}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -89,6 +95,7 @@ Global {69B94DB1-D1BE-4905-81AC-A5D49D0C9719} = {A19E7709-6AD8-4E9B-B3AB-4339C67D9F39} {1A9E20FE-6324-4839-A3AD-5726305122A5} = {A19E7709-6AD8-4E9B-B3AB-4339C67D9F39} {8E12DE14-0D83-48D8-964D-8B2BB06DB129} = {A19E7709-6AD8-4E9B-B3AB-4339C67D9F39} + {FDF81413-ABAD-4890-A60F-4FEC62DD2A7D} = {6F154F8D-3437-45EE-9D89-02B96BDF3E8E} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {FBA0CB49-EF2D-4538-9D00-FCEDA24879A9} diff --git a/DepartmentPortal/Security/SecurityBusinessLogic/BindingModels/AccessBindingModels.cs b/DepartmentPortal/Security/SecurityBusinessLogic/BindingModels/AccessBindingModels.cs index 3632eb2..35e587b 100644 --- a/DepartmentPortal/Security/SecurityBusinessLogic/BindingModels/AccessBindingModels.cs +++ b/DepartmentPortal/Security/SecurityBusinessLogic/BindingModels/AccessBindingModels.cs @@ -1,4 +1,5 @@ -using ModuleTools.Attributes; +using CoreModels.ModelsSecurity; +using ModuleTools.Attributes; using ModuleTools.BindingModels; using ModuleTools.Enums; using System; @@ -6,10 +7,10 @@ using System.ComponentModel.DataAnnotations; namespace SecurityBusinessLogic.BindingModels { - /// - /// Получение информации по доступу - /// - public class AccessGetBindingModel : GetBindingModel + /// + /// Получение информации по доступу + /// + public class AccessGetBindingModel : GetBindingModel { /// /// Для вывода списка доступов по роли в контроле десктопном @@ -20,7 +21,7 @@ namespace SecurityBusinessLogic.BindingModels /// /// Сохранение информации по доступу /// - public class AccessSetBindingModel : SetBindingModel + public class AccessSetBindingModel : SetBindingModel, IAccessModel { [MapConfiguration("RoleId")] public Guid RoleId { get; set; } diff --git a/DepartmentPortal/Security/SecurityBusinessLogic/BindingModels/EnviromentSettingBindingModels.cs b/DepartmentPortal/Security/SecurityBusinessLogic/BindingModels/EnviromentSettingBindingModels.cs index 36256a5..9429d38 100644 --- a/DepartmentPortal/Security/SecurityBusinessLogic/BindingModels/EnviromentSettingBindingModels.cs +++ b/DepartmentPortal/Security/SecurityBusinessLogic/BindingModels/EnviromentSettingBindingModels.cs @@ -1,4 +1,5 @@ -using ModuleTools.Attributes; +using CoreModels.ModelsSecurity; +using ModuleTools.Attributes; using ModuleTools.BindingModels; using System.ComponentModel.DataAnnotations; @@ -15,7 +16,7 @@ namespace SecurityBusinessLogic.BindingModels /// /// Сохранение общих настроек системы /// - public class EnviromentSettingSetBindingModel : SetBindingModel + public class EnviromentSettingSetBindingModel : SetBindingModel, IEnviromentSettingModel { [Required(ErrorMessage = "required")] [MapConfiguration("Key")] diff --git a/DepartmentPortal/Security/SecurityBusinessLogic/BindingModels/RoleBindingModels.cs b/DepartmentPortal/Security/SecurityBusinessLogic/BindingModels/RoleBindingModels.cs index c60bae7..20f1e6e 100644 --- a/DepartmentPortal/Security/SecurityBusinessLogic/BindingModels/RoleBindingModels.cs +++ b/DepartmentPortal/Security/SecurityBusinessLogic/BindingModels/RoleBindingModels.cs @@ -1,4 +1,5 @@ -using ModuleTools.Attributes; +using CoreModels.ModelsSecurity; +using ModuleTools.Attributes; using ModuleTools.BindingModels; using System.ComponentModel.DataAnnotations; @@ -12,7 +13,7 @@ namespace SecurityBusinessLogic.BindingModels /// /// Сохранение роли /// - public class RoleSetBindingModel : SetBindingModel + public class RoleSetBindingModel : SetBindingModel, IRoleModel { [Required(ErrorMessage = "required")] [MapConfiguration("RoleName")] diff --git a/DepartmentPortal/Security/SecurityBusinessLogic/BindingModels/UserBindingModels.cs b/DepartmentPortal/Security/SecurityBusinessLogic/BindingModels/UserBindingModels.cs index 1bd921b..75d216e 100644 --- a/DepartmentPortal/Security/SecurityBusinessLogic/BindingModels/UserBindingModels.cs +++ b/DepartmentPortal/Security/SecurityBusinessLogic/BindingModels/UserBindingModels.cs @@ -1,4 +1,5 @@ -using ModuleTools.Attributes; +using CoreModels.ModelsSecurity; +using ModuleTools.Attributes; using ModuleTools.BindingModels; using System; using System.ComponentModel.DataAnnotations; @@ -18,15 +19,15 @@ namespace SecurityBusinessLogic.BindingModels /// /// Сохранение пользователя /// - public class UserSetBindingModel : SetBindingModel + public class UserSetBindingModel : SetBindingModel, IUserModel { [Required(ErrorMessage = "required")] - [MapConfiguration("Login")] - public string Login { get; set; } + [MapConfiguration("UserName")] + public string UserName { get; set; } [Required(ErrorMessage = "required")] [MapConfiguration("Password")] - public string Password { get; set; } + public string PasswordHash { get; set; } [MapConfiguration("Avatar")] public byte[] Avatar { get; set; } @@ -42,5 +43,5 @@ namespace SecurityBusinessLogic.BindingModels [MapConfiguration("CountAttempt")] public int CountAttempt { get; set; } - } + } } \ No newline at end of file diff --git a/DepartmentPortal/Security/SecurityBusinessLogic/BindingModels/UserRoleBindingModels.cs b/DepartmentPortal/Security/SecurityBusinessLogic/BindingModels/UserRoleBindingModels.cs index d679a96..76a311e 100644 --- a/DepartmentPortal/Security/SecurityBusinessLogic/BindingModels/UserRoleBindingModels.cs +++ b/DepartmentPortal/Security/SecurityBusinessLogic/BindingModels/UserRoleBindingModels.cs @@ -1,4 +1,5 @@ -using ModuleTools.Attributes; +using CoreModels.ModelsSecurity; +using ModuleTools.Attributes; using ModuleTools.BindingModels; using System; using System.ComponentModel.DataAnnotations; @@ -18,7 +19,7 @@ namespace SecurityBusinessLogic.BindingModels /// /// Сохранение связи пользователя с ролью /// - public class UserRoleSetBindingModel : SetBindingModel + public class UserRoleSetBindingModel : SetBindingModel, IUserRoleModel { [Required(ErrorMessage = "required")] [MapConfiguration("UserId")] diff --git a/DepartmentPortal/Security/SecurityBusinessLogic/BusinessLogics/UserBusinessLogic.cs b/DepartmentPortal/Security/SecurityBusinessLogic/BusinessLogics/UserBusinessLogic.cs index 7b70e14..e7b27a5 100644 --- a/DepartmentPortal/Security/SecurityBusinessLogic/BusinessLogics/UserBusinessLogic.cs +++ b/DepartmentPortal/Security/SecurityBusinessLogic/BusinessLogics/UserBusinessLogic.cs @@ -39,8 +39,8 @@ namespace SecurityBusinessLogic.BusinessLogics { result = Service.Create(new UserSetBindingModel { - Login = model.Login, - Password = password + UserName = model.Login, + PasswordHash = password }); } if (!result.IsSucceeded) diff --git a/DepartmentPortal/Security/SecurityBusinessLogic/SecurityBusinessLogic.csproj b/DepartmentPortal/Security/SecurityBusinessLogic/SecurityBusinessLogic.csproj index a6fc255..e3bb8c2 100644 --- a/DepartmentPortal/Security/SecurityBusinessLogic/SecurityBusinessLogic.csproj +++ b/DepartmentPortal/Security/SecurityBusinessLogic/SecurityBusinessLogic.csproj @@ -9,6 +9,7 @@ + diff --git a/DepartmentPortal/Security/SecurityBusinessLogic/ViewModels/AccessViewModels.cs b/DepartmentPortal/Security/SecurityBusinessLogic/ViewModels/AccessViewModels.cs index 0d81f68..a9c9628 100644 --- a/DepartmentPortal/Security/SecurityBusinessLogic/ViewModels/AccessViewModels.cs +++ b/DepartmentPortal/Security/SecurityBusinessLogic/ViewModels/AccessViewModels.cs @@ -1,20 +1,21 @@ -using ModuleTools.Attributes; +using CoreModels.ModelsSecurity; +using ModuleTools.Attributes; using ModuleTools.Enums; using ModuleTools.ViewModels; using System; namespace SecurityBusinessLogic.ViewModels { - /// - /// Список достпуов - /// - public class AccessListViewModel : ListViewModel { } + /// + /// Список достпуов + /// + public class AccessListViewModel : ListViewModel { } /// /// Элемент доступа /// [ViewModelControlElementClass()] - public class AccessViewModel : ElementViewModel + public class AccessViewModel : ElementViewModel, IAccessModel { [ViewModelControlElementProperty("Роль", ControlType.ControlGuid, MustHaveValue = true, ReadOnly = true, ControlTypeObject = "SecurityWindowsDesktop.EntityControls.ControlRoleList, SecurityWindowsDesktop")] [MapConfiguration("RoleId", AllowCopyWithoutRigth = false)] diff --git a/DepartmentPortal/Security/SecurityBusinessLogic/ViewModels/EnviromentSettingViewModels.cs b/DepartmentPortal/Security/SecurityBusinessLogic/ViewModels/EnviromentSettingViewModels.cs index 61667ce..c0d88a2 100644 --- a/DepartmentPortal/Security/SecurityBusinessLogic/ViewModels/EnviromentSettingViewModels.cs +++ b/DepartmentPortal/Security/SecurityBusinessLogic/ViewModels/EnviromentSettingViewModels.cs @@ -1,4 +1,5 @@ -using ModuleTools.Attributes; +using CoreModels.ModelsSecurity; +using ModuleTools.Attributes; using ModuleTools.Enums; using ModuleTools.ViewModels; @@ -13,7 +14,7 @@ namespace SecurityBusinessLogic.ViewModels /// Элемент общих настроек системы /// [ViewModelControlElementClass()] - public class EnviromentSettingViewModel : ElementViewModel + public class EnviromentSettingViewModel : ElementViewModel, IEnviromentSettingModel { [ViewModelControlListProperty("Ключ")] [ViewModelControlElementProperty("Ключ", ControlType.ControlString, MustHaveValue = true, ReadOnly = true)] diff --git a/DepartmentPortal/Security/SecurityBusinessLogic/ViewModels/RoleViewModels.cs b/DepartmentPortal/Security/SecurityBusinessLogic/ViewModels/RoleViewModels.cs index 3a93125..e1f60a8 100644 --- a/DepartmentPortal/Security/SecurityBusinessLogic/ViewModels/RoleViewModels.cs +++ b/DepartmentPortal/Security/SecurityBusinessLogic/ViewModels/RoleViewModels.cs @@ -1,4 +1,5 @@ -using ModuleTools.Attributes; +using CoreModels.ModelsSecurity; +using ModuleTools.Attributes; using ModuleTools.Enums; using ModuleTools.ViewModels; @@ -17,7 +18,7 @@ namespace SecurityBusinessLogic.ViewModels ControlTypeObject = "SecurityWindowsDesktop.EntityControls.ControlAccessList, SecurityWindowsDesktop")] [ViewModelControlElementDependenceEntity(Title = "Пользователи", Order = 2, ParentPropertyName = "RoleId", ControlTypeObject = "SecurityWindowsDesktop.EntityControls.ControlUserRoleList, SecurityWindowsDesktop")] - public class RoleViewModel : ElementViewModel + public class RoleViewModel : ElementViewModel, IRoleModel { [ViewModelControlListProperty("Название роли")] [ViewModelControlElementProperty("Название роли", ControlType.ControlString, MustHaveValue = true)] diff --git a/DepartmentPortal/Security/SecurityBusinessLogic/ViewModels/UserRoleViewModels.cs b/DepartmentPortal/Security/SecurityBusinessLogic/ViewModels/UserRoleViewModels.cs index e474bd8..046f905 100644 --- a/DepartmentPortal/Security/SecurityBusinessLogic/ViewModels/UserRoleViewModels.cs +++ b/DepartmentPortal/Security/SecurityBusinessLogic/ViewModels/UserRoleViewModels.cs @@ -1,4 +1,5 @@ -using ModuleTools.Attributes; +using CoreModels.ModelsSecurity; +using ModuleTools.Attributes; using ModuleTools.Enums; using ModuleTools.ViewModels; using System; @@ -14,7 +15,7 @@ namespace SecurityBusinessLogic.ViewModels /// Элемент пользователей /// [ViewModelControlElementClass()] - public class UserRoleViewModel : ElementViewModel + public class UserRoleViewModel : ElementViewModel, IUserRoleModel { [ViewModelControlElementProperty("Пользователь", ControlType.ControlGuid, MustHaveValue = true, ReadOnly = false, ControlTypeObject = "SecurityWindowsDesktop.EntityControls.ControlUserList, SecurityWindowsDesktop")] [MapConfiguration("UserId", AllowCopyWithoutRigth = false)] diff --git a/DepartmentPortal/Security/SecurityBusinessLogic/ViewModels/UserViewModels.cs b/DepartmentPortal/Security/SecurityBusinessLogic/ViewModels/UserViewModels.cs index 803e232..525e433 100644 --- a/DepartmentPortal/Security/SecurityBusinessLogic/ViewModels/UserViewModels.cs +++ b/DepartmentPortal/Security/SecurityBusinessLogic/ViewModels/UserViewModels.cs @@ -1,4 +1,5 @@ -using ModuleTools.Attributes; +using CoreModels.ModelsSecurity; +using ModuleTools.Attributes; using ModuleTools.Enums; using ModuleTools.ViewModels; using System; @@ -16,15 +17,15 @@ namespace SecurityBusinessLogic.ViewModels [ViewModelControlElementClass(HaveDependenceEntities = true, Width = 800, Height = 400)] [ViewModelControlElementDependenceEntity(Title = "Роли", Order = 1, ParentPropertyName = "UserId", ControlTypeObject = "SecurityWindowsDesktop.EntityControls.ControlUserRoleList, SecurityWindowsDesktop")] - public class UserViewModel : ElementViewModel + public class UserViewModel : ElementViewModel, IUserModel { [ViewModelControlListProperty("Пользователь")] [ViewModelControlElementProperty("Логин", ControlType.ControlString, MustHaveValue = true)] [MapConfiguration("UserName")] - public string Login { get; set; } + public string UserName { get; set; } [MapConfiguration("PasswordHash", AllowCopyWithoutRigth = false)] - public string Password { get; set; } + public string PasswordHash { get; set; } [ViewModelControlElementProperty("Фото", ControlType.ControlImage, Width = 200, Height = 200)] [MapConfiguration("Avatar")] diff --git a/DepartmentPortal/Security/SecurityDatabaseImplementation/Implementations/UserService.cs b/DepartmentPortal/Security/SecurityDatabaseImplementation/Implementations/UserService.cs index 726fb8f..99abcf4 100644 --- a/DepartmentPortal/Security/SecurityDatabaseImplementation/Implementations/UserService.cs +++ b/DepartmentPortal/Security/SecurityDatabaseImplementation/Implementations/UserService.cs @@ -22,11 +22,11 @@ namespace SecurityDatabaseImplementation.Implementations { protected override OperationResultModel AdditionalCheckingWhenAdding(DbContext context, UserSetBindingModel model) { - if (model.Password.IsEmpty()) + if (model.PasswordHash.IsEmpty()) { - model.Password = "qwerty"; + model.PasswordHash = "qwerty"; } - model.Password = SecurityManager.GetPasswordHash(model.Password); + model.PasswordHash = SecurityManager.GetPasswordHash(model.PasswordHash); return OperationResultModel.Success(null); } @@ -69,7 +69,7 @@ namespace SecurityDatabaseImplementation.Implementations context.SaveChanges(); } - protected override User GetUniqueEntity(UserSetBindingModel model, DbContext context) => context.Set().FirstOrDefault(x => x.UserName == model.Login && x.Id != model.Id); + protected override User GetUniqueEntity(UserSetBindingModel model, DbContext context) => context.Set().FirstOrDefault((System.Linq.Expressions.Expression>)(x => x.UserName == model.UserName && x.Id != model.Id)); protected override IQueryable IncludingWhenReading(IQueryable query) => query;