Introduction
Each Core Identity can have zero to N employments, whereas an employment is the combination of an organizational unit assignment, an optional function, an optional employment type, a validity range and optional attributes.
Properties
Whenever you are creating or updating an employment, you have to specify the following properties:
Property | Data Type | Mandatory | Example | Description |
---|---|---|---|---|
| Date |
| 1.1.2022 | When the employment validity starts |
| Date | 31.12.2030 | When the employment validity ends | |
| Int |
| 1 | A unique number of the employment |
| Int | 100 | The employments percentage. Will affect the main employment calculation. | |
| DropDown | CEO | The associated function. | |
| DropDown |
| ITSENSE AG | The organizational assignment. |
| DropDown | Intern | The associated employment type. | |
| DropDown |
| Active | The state of the employment. |
| Bool | True | Indicates if this is the main employment or not. |
Main Employment
If a person has more than one employment, there is often a need to determinate its main employment. This can be used in many places such as mappings. For example a Core Identity can have two employments but you would like to provision its job title to a target system. In order to determinate the job title, the main employment is used.
The rules to choose the main employment are as following:
Only consider employments, which are not in state “deleted”, then:
Main Employment is set
Order by
Valid From and not expired
Percentage
Has valid to
Valid to
Id
The actual implementation might clear up any remaining questions:
return employments .Where(a => a.EmploymentState.Id != (uint)CoreIdentityEmploymentStates.Deleted) .OrderByDescending(a => a.EmploymentState.Id) .ThenByDescending(a => a.MainEmployment) .ThenByDescending(a => a.ValidFrom <= DateTime.Now && (!a.ValidTo.HasValue || a.ValidTo.Value >= DateTime.Now.Date)) .ThenByDescending(a => a.Percentage) .ThenBy(a => a.ValidFrom) .ThenBy(a => a.ValidTo.HasValue) .ThenBy(a => a.ValidTo) .ThenBy(a => a.Id);
For further information there are also how-tos related to this topic: