# TASK 3.2: Migrate /warehouse/orders Endpoints to a Branch-Aligned Redshift Contract

## Summary

Migrate the current `/warehouse/orders` endpoint handlers from `KDSContext` to a branch-aligned Redshift runtime read service.

This task should preserve public response DTOs where practical.

Status: deferred.

`WarehouseOrderEndpoints.cs` still exists in the branch, but the earlier canonical Redshift order service was removed and the endpoint contract has not been realigned to the source-mirror `curated` model.

## Dependencies

- TASK 3.1 (branch-aligned Redshift runtime read service)

## Files to Modify

### 1. `backend/Kds.Ai.ApiService/Endpoints/WarehouseOrderEndpoints.cs`

Replace direct EF Core `KDSContext` usage with the branch-aligned Redshift runtime read service.

Update endpoint descriptions that reference source tables or source fields.

### 2. API DI registration

Register the order read service in the API service module/startup path.

## Required Behavior

Migrated endpoints must:

- resolve a tenant through the runtime tenant resolver,
- read from tenant Redshift using the branch-aligned runtime contract,
- preserve existing routes where practical,
- preserve existing response DTOs where practical,
- avoid source field names in endpoint descriptions,
- avoid `KDSContext` in migrated handlers.

Endpoint descriptions should not mention:

- `kdsdev`,
- `CreateTime`,
- `Done`,
- `ItemsCount`,
- `PreparationTime`,
- `is_deleted`.

## Status

Deferred.

## Acceptance Criteria

- [ ] `/warehouse/orders/count-today` reads from Redshift
- [ ] `/warehouse/orders/per-hour` reads from Redshift
- [ ] `/warehouse/orders/average-preparation-time` reads from Redshift
- [ ] `/warehouse/orders/by-order-type` reads from Redshift
- [ ] `/warehouse/orders/by-destination` reads from Redshift
- [ ] `/warehouse/orders/active` reads from Redshift
- [ ] `/warehouse/orders/average-items-per-order` reads from Redshift
- [ ] `/warehouse/orders/top-items` reads from Redshift
- [ ] Migrated handlers no longer take `KDSContext`
- [ ] Endpoint descriptions no longer reference `kdsdev`
- [ ] Response DTOs remain compatible unless a change is documented
- [x] Solution builds without errors

## Notes

- Keep this migration focused on covered order/item endpoints.
- Do not migrate unrelated API endpoints in this task.
- Do not implement authenticated tenant RBAC here.
