---
title: EmployeeDirectoryService
summary: API reference for EmployeeDirectoryService.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-09-24
library: SAIF.Services
reference_type: package
---

# EmployeeDirectoryService

Implements `IEmployeeDirectoryService`, building the active-employee directory view including a given employee's direct reports and peers. It depends on `IUnitOfWork` (retained but unused after construction) and `IRepository<Employee>` for data access, and registers an AutoMapper map for `Employee`→`Employee` (data model to contract) in its constructor.

## Purpose
- Lists all active employees (`EmployeeStatusCode == "A"`), ordered by last name.
- Retrieves a single employee's full contract, populated with their active direct reports, active peers (same supervisor, excluding self), and mapped supervisor.

## Context
- Namespace: `SAIF.Services.Employees`
- Assembly/package: `SAIF.Services` (packaged inside the `SAIF.SAIFCode.Core` NuGet package)

## Public members
| Member | Signature | Purpose |
| --- | --- | --- |
| EmployeeDirectoryService(...) | `public EmployeeDirectoryService(IUnitOfWork uow, IRepository<DataModel.Employee> employeeRepository)` | Stores the unit of work and employee repository, and registers the `Employee` data-model-to-contract AutoMapper map (instance-level, not static). |
| GetEmployees | `public IEnumerable<Employee> GetEmployees()` | Returns all employees with an active status code, mapped to `Employee` contracts and ordered by last name. |
| GetEmployee | `public Employee GetEmployee(string employeeId)` | Returns the mapped `Employee` matching `employeeId` (throws if not found, per `.First`), populated with active direct reports, active peers under the same supervisor, and a mapped supervisor. |

## Behavioral notes
- The AutoMapper map for `Employee` is registered per-instance in the constructor rather than in a static constructor (unlike most other services in this library), so it is re-registered every time the service is instantiated*.
- `GetEmployee` uses `.First` rather than `.FirstOrDefault`, so an unmatched `employeeId` results in a thrown `InvalidOperationException` rather than a `null` return*.

> **Note:** Statements marked with * were inferred from code structure, naming conventions, or
> contextual evidence where direct confirmation was not available in source artifacts. Statements
> marked with ** could not be confirmed; treat as unknown until verified.

## Sources
- Services/SAIF.Services/Employees/EmployeeDirectoryService.cs
