Employee Application Layer
Summary
The Application layer coordinates Employee and Organization use cases through custom CQRS handlers, legacy-style application services, repository/search ports, validators, DTOs, mappings, audit recording, tenant context, and a unit of work.
Audience
- Backend developers
- QA engineers and solution architects
Reference Content
Commands and handlers
Typed command records and scoped handlers cover employee creation/update, status, department, manager, notes, and document-reference changes. Handlers validate, load aggregates through ports, invoke domain behavior, record audit information, commit through the unit of work, and return a lightweight result type.
Queries and handlers
Typed queries and scoped handlers cover employee lookup, search, timeline, department listing, and designation listing. Read paths use projections or no-tracking queries and do not raise domain events.
Parallel application-service surface
EmployeeCommands and EmployeeQueries implement an earlier/direct application-service style alongside the newer typed CQRS handlers. DepartmentService and DesignationService coordinate organization use cases. The coexistence is source-confirmed and transitional; consolidation direction Requires confirmation.
DTOs and mapping
Application DTOs represent employee core data, profile collections, employment state, timeline entries, notes, document metadata, departments, and designations. EmployeeMappings converts domain objects to responses and search hits to list items. A second internal mapping helper exists in Employees.cs, creating some duplication.
Validation
Async validators perform tenant, required-field, uniqueness, and cross-entity checks before typed command handlers mutate aggregates. Domain value objects and aggregate methods perform invariant validation. No implemented reusable pipeline behavior automatically invokes validators.
Application ports
Confirmed ports include repositories, employee search, audit writer, unit of work, and tenant context. Infrastructure supplies their runtime implementations.
Source References
microservices/src/employee-service/Application/Common/Cqrs.csmicroservices/src/employee-service/Application/Common/Abstractions.csmicroservices/src/employee-service/Application/Commands/EmployeeApplicationCommands.csmicroservices/src/employee-service/Application/Queries/EmployeeApplicationQueries.csmicroservices/src/employee-service/Application/Employees/Employees.csmicroservices/src/employee-service/Application/Mappings/EmployeeMappings.csmicroservices/src/employee-service/Application/Validators/EmployeeCommandValidators.cs
Related Articles
See Also
Keywords
- Use-case coordination
- Command handler
- Query projection
Revision Information
- Status: Draft
- Last reviewed: 2026-07-15
- Review cycle: Quarterly