From 94b54e712ec1c5af9be2f3f2802c7481b8573f1a Mon Sep 17 00:00:00 2001 From: kotcheshir73 Date: Sat, 3 Apr 2021 08:05:01 +0400 Subject: [PATCH] =?UTF-8?q?=D0=B1=D0=B8=D0=B7=D0=BD=D0=B5=D1=81-=D0=BB?= =?UTF-8?q?=D0=BE=D0=B3=D0=B8=D0=BA=D0=B0=20=D1=81=D0=BE=D1=82=D1=80=D1=83?= =?UTF-8?q?=D0=B4=D0=BD=D0=B8=D0=BA=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BindingModels/EmployeeBindingModels.cs | 57 +++++++++++++ .../BusinessLogics/EmployeeBusinessLogic.cs | 16 ++++ .../Interfaces/IEmployeeService.cs | 10 +++ .../ViewModels/EmployeeViewModels.cs | 81 +++++++++++++++++++ 4 files changed, 164 insertions(+) create mode 100644 DepartmentPortal/Department/DepartmentBusinessLogic/BindingModels/EmployeeBindingModels.cs create mode 100644 DepartmentPortal/Department/DepartmentBusinessLogic/BusinessLogics/EmployeeBusinessLogic.cs create mode 100644 DepartmentPortal/Department/DepartmentBusinessLogic/Interfaces/IEmployeeService.cs create mode 100644 DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/EmployeeViewModels.cs diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/BindingModels/EmployeeBindingModels.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/BindingModels/EmployeeBindingModels.cs new file mode 100644 index 0000000..7a69e2a --- /dev/null +++ b/DepartmentPortal/Department/DepartmentBusinessLogic/BindingModels/EmployeeBindingModels.cs @@ -0,0 +1,57 @@ +using ModuleTools.Attributes; +using ModuleTools.BindingModels; +using System; +using System.ComponentModel.DataAnnotations; + +namespace DepartmentBusinessLogic.BindingModels +{ + public class EmployeeGetBindingModel : GetBindingModel + { + } + + public class EmployeeSetBindingModel : SetBindingModel + { + [Required(ErrorMessage = "required")] + [MapConfiguration("UserId")] + public Guid UserId { get; set; } + + [Required(ErrorMessage = "required")] + [MapConfiguration("FirstName")] + public string FirstName { get; set; } + + [Required(ErrorMessage = "required")] + [MapConfiguration("LastName")] + public string LastName { get; set; } + + [MapConfiguration("Patronymic")] + public string Patronymic { get; set; } + + [Required(ErrorMessage = "required")] + [MapConfiguration("DateBirth")] + public DateTime DateBirth { get; set; } + + [Required(ErrorMessage = "required")] + [MapConfiguration("Address")] + public string Address { get; set; } + + [Required(ErrorMessage = "required")] + [MapConfiguration("Email")] + public string Email { get; set; } + + [Required(ErrorMessage = "required")] + [MapConfiguration("MobileNumber")] + public string MobileNumber { get; set; } + + [MapConfiguration("HomeNumber")] + public string HomeNumber { get; set; } + + [MapConfiguration("Description")] + public string Description { get; set; } + + [MapConfiguration("Photo")] + public byte[] Photo { get; set; } + + [MapConfiguration("GroupElectricalSafety")] + public string GroupElectricalSafety { get; set; } + } +} \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/BusinessLogics/EmployeeBusinessLogic.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/BusinessLogics/EmployeeBusinessLogic.cs new file mode 100644 index 0000000..90fce14 --- /dev/null +++ b/DepartmentPortal/Department/DepartmentBusinessLogic/BusinessLogics/EmployeeBusinessLogic.cs @@ -0,0 +1,16 @@ +using DepartmentBusinessLogic.BindingModels; +using DepartmentBusinessLogic.Interfaces; +using DepartmentBusinessLogic.ViewModels; +using ModuleTools.BusinessLogics; +using ModuleTools.Enums; + +namespace DepartmentBusinessLogic.BusinessLogics +{ + /// + /// Логика работы с должностями сотрудников + /// + public class EmployeeBusinessLogic : GenericBusinessLogic + { + public EmployeeBusinessLogic(IEmployeeService service) : base(service, "Сотрудники", AccessOperation.Сотрудники) { } + } +} \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/Interfaces/IEmployeeService.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/Interfaces/IEmployeeService.cs new file mode 100644 index 0000000..7331f0c --- /dev/null +++ b/DepartmentPortal/Department/DepartmentBusinessLogic/Interfaces/IEmployeeService.cs @@ -0,0 +1,10 @@ +using DepartmentBusinessLogic.BindingModels; +using ModuleTools.Interfaces; + +namespace DepartmentBusinessLogic.Interfaces +{ + /// + /// Хранение сотрудников + /// + public interface IEmployeeService : IGenerticEntityService { } +} \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/EmployeeViewModels.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/EmployeeViewModels.cs new file mode 100644 index 0000000..865015d --- /dev/null +++ b/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/EmployeeViewModels.cs @@ -0,0 +1,81 @@ +using ModuleTools.Attributes; +using ModuleTools.Enums; +using ModuleTools.Extensions; +using ModuleTools.ViewModels; +using System; + +namespace DepartmentBusinessLogic.ViewModels +{ + /// + /// Список ролей + /// + public class EmployeeListViewModel : ListViewModel { } + + /// + /// Элемент ролей + /// + [ViewModelControlElementClass(HaveDependenceEntities = true, Width = 800, Height = 500)] + //[ViewModelControlElementDependenceEntity(Title = "Сотрудники", Order = 1, ParentPropertyName = "EmployeePostId", + // ControlTypeObject = "SecurityWindowsDesktop.EntityControls.ControlRoleUserList, SecurityWindowsDesktop")] + public class EmployeeViewModel : ElementViewModel + { + [MapConfiguration("UserId")] + public Guid UserId { get; set; } + + [ViewModelControlListProperty("Имя")] + [ViewModelControlElementProperty("Имя", ControlType.ControlString, MustHaveValue = true)] + [MapConfiguration("FirstName")] + public string FirstName { get; set; } + + [ViewModelControlListProperty("Фамилия")] + [ViewModelControlElementProperty("Фамилия", ControlType.ControlString, MustHaveValue = true)] + [MapConfiguration("LastName")] + public string LastName { get; set; } + + [ViewModelControlListProperty("Отчество")] + [ViewModelControlElementProperty("Отчество", ControlType.ControlString, MustHaveValue = true)] + [MapConfiguration("Patronymic")] + public string Patronymic { get; set; } + + [ViewModelControlListProperty("Отчество")] + [ViewModelControlElementProperty("Отчество", ControlType.ControlDateTime, MustHaveValue = true)] + [MapConfiguration("DateBirth")] + public DateTime DateBirth { get; set; } + + [ViewModelControlListProperty("Адрес")] + [ViewModelControlElementProperty("Адрес", ControlType.ControlString, MustHaveValue = true)] + [MapConfiguration("Address")] + public string Address { get; set; } + + [ViewModelControlListProperty("Эл. почта")] + [ViewModelControlElementProperty("Эл. почта", ControlType.ControlString, MustHaveValue = true)] + [MapConfiguration("Email")] + public string Email { get; set; } + + [ViewModelControlListProperty("Моб. номер")] + [ViewModelControlElementProperty("Моб. номер", ControlType.ControlString, MustHaveValue = true)] + [MapConfiguration("MobileNumber")] + public string MobileNumber { get; set; } + + [ViewModelControlListProperty("Дом. номер")] + [ViewModelControlElementProperty("Дом. номер", ControlType.ControlString, MustHaveValue = true)] + [MapConfiguration("HomeNumber")] + public string HomeNumber { get; set; } + + [ViewModelControlElementProperty("Описание", ControlType.ControlText, MustHaveValue = true)] + [MapConfiguration("Description")] + public string Description { get; set; } + + [ViewModelControlElementProperty("Фото", ControlType.ControlImage, MustHaveValue = true)] + [MapConfiguration("Photo")] + public byte[] Photo { get; set; } + + [ViewModelControlListProperty("Группа эл.безоп")] + [ViewModelControlElementProperty("Группа эл.безоп", ControlType.ControlString, MustHaveValue = true)] + [MapConfiguration("GroupElectricalSafety")] + public string GroupElectricalSafety { get; set; } + + public override string ToString() => + $"{LastName}{(FirstName.IsNotEmpty() ? $" {FirstName[0]}." : string.Empty)}{(Patronymic.IsNotEmpty() ? $"{Patronymic[0]}." : string.Empty)}"; + } +} \ No newline at end of file