Repository navigation
fix: resolve the open review issues (#11, #13) - #27
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
EmployeeRepository.cs:17-30, materialised with.ToList()atEmployeeService.cs:106. Closed.employeeDto.JobTitleNameis gone. Test:AddEmployeeAsync_DoesNotModifyTheCallersDto.ToDtonow maps from theProjectSummaryread model (ProjectService.cs:22-32) with names aggregated in SQL (ProjectRepository.cs:11-18); no navigation is touched. Closed.ToDto(JobTitles)now setsJobTitleName. 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 realCachedJobTitleRepository.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: succeedsFixes #11
Fixes #13