Skip to content

fix: resolve the open review issues (#11, #13) - #27

Merged
Menzi-Thami merged 2 commits into
masterfrom
fix/open-review-issues
Oct 6, 2026
Merged

Menzi-Thami merged 2 commits into
masterfrom
fix/open-review-issues

Conversation

@Menzi-Thami

Copy link
Copy Markdown
Owner

Resolves the four issues filed by the 2026-09-16 scheduled review. Two were already fixed by #23 and are closed with evidence; the other two are fixed here, one commit each, each with a test that fails before the fix.

Issue Outcome
#10 GetAllEmployeesAsync lazy O(n x m) lookup Already fixed by #23 (a546353): single JOIN with Dapper multi-mapping in EmployeeRepository.cs:17-30, materialised with .ToList() at EmployeeService.cs:106. Closed.
#11 AddEmployeeAsync mutates the caller's DTO Fixed here (cf5c42e). The job title existence check stays (missing title is still a 400); the write to employeeDto.JobTitleName is gone. Test: AddEmployeeAsync_DoesNotModifyTheCallersDto.
#12 ProjectService.ToDto dereferences unloaded navigations Already fixed by #23 (de9b8b8): ToDto now maps from the ProjectSummary read model (ProjectService.cs:22-32) with names aggregated in SQL (ProjectRepository.cs:11-18); no navigation is touched. Closed.
#13 GetAllJobTitlesAsync returns null names Fixed here (b6c9afa). ToDto(JobTitles) now sets JobTitleName. The Dapper query (SELECT Id, JobTitle FROM JobTitle) and the HybridCache round-trip were already correct; only the DTO mapping dropped the name. Nothing relied on the null (no controller or view calls the service method). Test: GetAllJobTitlesAsync_MapsEachJobTitlesName_WhenServedFromTheCache, run through the real CachedJobTitleRepository.

Checks run locally:

  • dotnet build -c Release --no-incremental: 0 errors, 28 warnings (unchanged from master)
  • dotnet test -c Release: 48 passed, 0 failed (46 before, plus the two new tests)
  • dotnet publish EmployeeApi -c Release: succeeds

Fixes #11
Fixes #13

AddEmployeeAsync looked up the job title to validate it, then copied its name
into employeeDto.JobTitleName. ToEntity never reads that property, so the write
changed nothing that was persisted; it only mutated an object the caller still
owns. Keep the existence check (it turns a missing job title into a 400 rather
than an FK violation) and drop the assignment.

Why: a service should not have side effects on its inputs that it does not use.

Test: AddEmployeeAsync_DoesNotModifyTheCallersDto fails before this change.

Fixes #11
ToDto(JobTitles) set only Id, so every JobTitleDto came back with a null
JobTitleName. That was kept on purpose when AutoMapper was removed, because the
old profile left it null too (source member "JobTitle", destination
"JobTitleName"). Job titles are now cached and meant to feed the UI, so a list
of ids with no names is a defect, not behaviour worth preserving.

The data path was already correct: JobTitleRepository selects "Id, JobTitle"
from the JobTitle table into JobTitles.Id/JobTitle, and CachedJobTitleRepository
round-trips both properties. Only the DTO mapping dropped the name. Nothing
relied on the null: no controller or view calls the service method (the
/api/v1/jobtitle endpoint reads the repository directly).

Why: callers of GetAllJobTitlesAsync need the names, not just the ids.

Test: GetAllJobTitlesAsync_MapsEachJobTitlesName_WhenServedFromTheCache runs the
service over the real HybridCache decorator and fails before this change.

Fixes #13
@Menzi-Thami
Menzi-Thami merged commit fa1a85c into master Oct 6, 2026
6 checks passed
@Menzi-Thami
Menzi-Thami deleted the fix/open-review-issues branch October 6, 2026 08:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GetAllJobTitlesAsync returns job titles whose name is always null AddEmployeeAsync mutates the caller's DTO to no effect

1 participant