Feat/services evaluation#35
Conversation
| var fieldErrors = ex.Errors.Select(e => | ||
| { | ||
| var domainKey = e.ErrorMessage; | ||
| var domainKey = e.ErrorCode; |
There was a problem hiding this comment.
Those were optional fixes I added to improve the ERR900 validation error display.
| var fieldErrors = failures.Select(f => | ||
| { | ||
| var domainKey = f.ErrorMessage; | ||
| var domainKey = f.ErrorCode; |
| public async Task AddAsync(ServiceEvaluation evaluation, CancellationToken ct) | ||
| { | ||
| _db.ServiceEvaluations.Add(evaluation); | ||
| await _db.SaveChangesAsync(ct).ConfigureAwait(false); |
There was a problem hiding this comment.
we don't use save changes in repo we use it in the handler for transaction handing so please review again
| [Audited] | ||
| public sealed class ServiceEvaluation : AuditableEntity<System.Guid> | ||
| { | ||
| private static readonly System.Guid AnonymousVisitorId = new("00000000-0000-0000-0000-000000000001"); |
There was a problem hiding this comment.
don't pass static userid here
| CancellationToken cancellationToken) | ||
| { | ||
| var evaluations = await _db.ServiceEvaluations | ||
| .OrderByDescending(e => e.CreatedOn) |
There was a problem hiding this comment.
add pagenation to this list
| userId, | ||
| _clock); | ||
|
|
||
| await _repository.AddAsync(evaluation, cancellationToken).ConfigureAwait(false); |
There was a problem hiding this comment.
as i mentioned in faq pr same comment here to use the unit of work to save the transaction
| CancellationToken ct) => | ||
| { | ||
| if (!Enum.IsDefined(typeof(EvaluationRating), body.OverallSatisfaction) || body.OverallSatisfaction == 0) | ||
| return Results.BadRequest(new { error = "OverallSatisfaction must be 1-5 (1=Excellent, 2=Satisfied, 3=Neutral, 4=Dissatisfied, 5=Poor)." }); |
There was a problem hiding this comment.
// the endpoint currently contains business/input validation rules
// and repeats the same pattern 3 times.
// moving this to validator
would keep the endpoint thinner and centralize validation behavior.
| .IsInEnum().WithErrorCode("INVALID_ENUM") | ||
| .NotEqual(EvaluationRating.None).WithErrorCode("REQUIRED_FIELD"); | ||
| RuleFor(x => x.EaseOfUse) | ||
| .IsInEnum().WithErrorCode("INVALID_ENUM") |
There was a problem hiding this comment.
// we can keep only the version with error codes
to avoid duplicate validation execution and improve readability.
Summary
Test plan
dotnet test backend/CCE.slngreenpnpm nx run-many -t lint,testgreen./scripts/check-contracts-clean.shgreenpnpm nx run-many -t e2e(web-portal-e2e + admin-cms-e2e) greenSecurity checklist
BRD traceability
Screenshots / output (optional)