Логика связей сотрудников и должностей

This commit is contained in:
kotcheshir73 2021-04-03 09:18:19 +04:00
parent 94b54e712e
commit 999fb75c98
7 changed files with 144 additions and 9 deletions

View File

@ -5,10 +5,16 @@ using System.ComponentModel.DataAnnotations;
namespace DepartmentBusinessLogic.BindingModels
{
/// <summary>
/// Получение сотрудника
/// </summary>
public class EmployeeGetBindingModel : GetBindingModel
{
}
/// <summary>
/// Сохранение сотрудника
/// </summary>
public class EmployeeSetBindingModel : SetBindingModel
{
[Required(ErrorMessage = "required")]

View File

@ -0,0 +1,41 @@
using ModuleTools.Attributes;
using ModuleTools.BindingModels;
using System;
using System.ComponentModel.DataAnnotations;
namespace DepartmentBusinessLogic.BindingModels
{
/// <summary>
/// Получение связи сотрудника с должностью
/// </summary>
public class EmployeeEmployeePostGetBindingModel : GetBindingModel
{
public Guid? EmployeeId { get; set; }
public Guid? EmployeePostId { get; set; }
}
/// <summary>
/// Сохранение связи сотрудника с должностью
/// </summary>
public class EmployeeEmployeePostSetBindingModel : SetBindingModel
{
[Required(ErrorMessage = "required")]
[MapConfiguration("EmployeeId")]
public Guid EmployeeId { get; set; }
[Required(ErrorMessage = "required")]
[MapConfiguration("EmployeePostId")]
public Guid EmployeePostId { get; set; }
[Required(ErrorMessage = "required")]
[MapConfiguration("Rate")]
public decimal Rate { get; set; }
[MapConfiguration("IsInternalCombination")]
public bool IsInternalCombination { get; set; }
[MapConfiguration("IsExternalCombination")]
public bool IsExternalCombination { get; set; }
}
}

View File

@ -4,10 +4,16 @@ using System.ComponentModel.DataAnnotations;
namespace DepartmentBusinessLogic.BindingModels
{
/// <summary>
/// Получение должности сотрудника
/// </summary>
public class EmployeePostGetBindingModel : GetBindingModel
{
}
/// <summary>
/// Сохранение должности сотрудника
/// </summary>
public class EmployeePostSetBindingModel : SetBindingModel
{
[Required(ErrorMessage = "required")]

View File

@ -0,0 +1,16 @@
using DepartmentBusinessLogic.BindingModels;
using DepartmentBusinessLogic.Interfaces;
using DepartmentBusinessLogic.ViewModels;
using ModuleTools.BusinessLogics;
using ModuleTools.Enums;
namespace DepartmentBusinessLogic.BusinessLogics
{
/// <summary>
/// Логика работы со связями сотрудников и должностей
/// </summary>
public class EmployeeEmployeePostBusinessLogic : GenericBusinessLogic<EmployeeEmployeePostGetBindingModel, EmployeeEmployeePostSetBindingModel, EmployeeEmployeePostListViewModel, EmployeeEmployeePostViewModel>
{
public EmployeeEmployeePostBusinessLogic(IEmployeeEmployeePostService service) : base(service, "Должности сотрудников", AccessOperation.Сотрудники) { }
}
}

View File

@ -0,0 +1,10 @@
using DepartmentBusinessLogic.BindingModels;
using ModuleTools.Interfaces;
namespace DepartmentBusinessLogic.Interfaces
{
/// <summary>
/// Хранение связей сотрудников и должностей
/// </summary>
public interface IEmployeeEmployeePostService : IGenerticEntityService<EmployeeEmployeePostGetBindingModel, EmployeeEmployeePostSetBindingModel> { }
}

View File

@ -0,0 +1,56 @@
using ModuleTools.Attributes;
using ModuleTools.Enums;
using ModuleTools.ViewModels;
using System;
namespace DepartmentBusinessLogic.ViewModels
{
/// <summary>
/// Список связей сотрудников и должностей
/// </summary>
public class EmployeeEmployeePostListViewModel : ListViewModel<EmployeeEmployeePostViewModel> { }
/// <summary>
/// Связь сотрудника и должности
/// </summary>
[ViewModelControlElementClass()]
public class EmployeeEmployeePostViewModel : ElementViewModel
{
[MapConfiguration("EmployeeId", AllowCopyWithoutRigth = false)]
// [ViewModelControlElementProperty("Сотрудник", ControlType.ControlGuid, MustHaveValue = true, ReadOnly = false, ControlTypeObject = "SecurityWindowsDesktop.EntityControls.ControlUserList, SecurityWindowsDesktop")]
public Guid EmployeeId { get; set; }
[ViewModelControlListProperty("Сотрудник")]
[MapConfiguration("Employee.LastName", IsDifficle = true)]
public string EmployeeName { get; set; }
[MapConfiguration("EmployeePostId")]
//[ViewModelControlElementProperty("Должность", ControlType.ControlGuid, MustHaveValue = true, ReadOnly = false, ControlTypeObject = "SecurityWindowsDesktop.EntityControls.ControlRoleList, SecurityWindowsDesktop")]
public Guid EmployeePostId { get; set; }
[ViewModelControlListProperty("Должность")]
[MapConfiguration("EmployeePost.PostName", IsDifficle = true)]
public string EmployeePostName { get; set; }
[ViewModelControlListProperty("Ставка", 80)]
[ViewModelControlElementProperty("Ставка", ControlType.ControlDecimal, MustHaveValue = true)]
[MapConfiguration("Rate")]
public decimal Rate { get; set; }
[ViewModelControlElementProperty("Внутр. совм.", ControlType.ControlBool)]
[MapConfiguration("IsInternalCombination")]
public bool IsInternalCombination { get; set; }
[ViewModelControlListProperty("Внутр. совм.", 80)]
public string InternalCombination => IsInternalCombination ? "Да" : "Нет";
[ViewModelControlElementProperty("Внеш. совм.", ControlType.ControlBool)]
[MapConfiguration("IsExternalCombination")]
public bool IsExternalCombination { get; set; }
[ViewModelControlListProperty("Внеш. совм.", 80)]
public string ExternalCombination => IsExternalCombination ? "Да" : "Нет";
public override string ToString() => $"{EmployeeName}-{EmployeePostName}";
}
}

View File

@ -7,12 +7,12 @@ using System;
namespace DepartmentBusinessLogic.ViewModels
{
/// <summary>
/// Список ролей
/// Список сотрудников
/// </summary>
public class EmployeeListViewModel : ListViewModel<EmployeeViewModel> { }
/// <summary>
/// Элемент ролей
/// Элемент сотрудник
/// </summary>
[ViewModelControlElementClass(HaveDependenceEntities = true, Width = 800, Height = 500)]
//[ViewModelControlElementDependenceEntity(Title = "Сотрудники", Order = 1, ParentPropertyName = "EmployeePostId",
@ -39,27 +39,27 @@ namespace DepartmentBusinessLogic.ViewModels
[ViewModelControlListProperty("Отчество")]
[ViewModelControlElementProperty("Отчество", ControlType.ControlDateTime, MustHaveValue = true )]
[MapConfiguration("DateBirth")]
[MapConfiguration("DateBirth", AllowCopyWithoutRigth = false)]
public DateTime DateBirth { get; set; }
[ViewModelControlListProperty("Адрес")]
[ViewModelControlElementProperty("Адрес", ControlType.ControlString, MustHaveValue = true)]
[MapConfiguration("Address")]
[MapConfiguration("Address", AllowCopyWithoutRigth = false)]
public string Address { get; set; }
[ViewModelControlListProperty("Эл. почта")]
[ViewModelControlElementProperty("Эл. почта", ControlType.ControlString, MustHaveValue = true)]
[MapConfiguration("Email")]
[MapConfiguration("Email", AllowCopyWithoutRigth = false)]
public string Email { get; set; }
[ViewModelControlListProperty("Моб. номер")]
[ViewModelControlElementProperty("Моб. номер", ControlType.ControlString, MustHaveValue = true)]
[MapConfiguration("MobileNumber")]
[MapConfiguration("MobileNumber", AllowCopyWithoutRigth = false)]
public string MobileNumber { get; set; }
[ViewModelControlListProperty("Дом. номер")]
[ViewModelControlElementProperty("Дом. номер", ControlType.ControlString, MustHaveValue = true)]
[MapConfiguration("HomeNumber")]
[MapConfiguration("HomeNumber", AllowCopyWithoutRigth = false)]
public string HomeNumber { get; set; }
[ViewModelControlElementProperty("Описание", ControlType.ControlText, MustHaveValue = true)]