Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Whenever you are creating or updating an emplyomentemployment, you have to specify the following properties:

...

If a person has more than one employment, there is often a need to determinate its main employment. This is can be used in many places such as mappings. For example a Core Identity can have two emplyoments 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.

...

  • 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:

Code Block
languagec#
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:

https://itsense.atlassian.net/l/cp/21118Xwy