Skip to content

Feat/services evaluation#35

Open
ahmed12348 wants to merge 3 commits into
developfrom
feat/services-evaluation
Open

Feat/services evaluation#35
ahmed12348 wants to merge 3 commits into
developfrom
feat/services-evaluation

Conversation

@ahmed12348
Copy link
Copy Markdown
Collaborator

Summary

Test plan

  • dotnet test backend/CCE.sln green
  • pnpm nx run-many -t lint,test green
  • If API surface changed: ./scripts/check-contracts-clean.sh green
  • If UI changed: pnpm nx run-many -t e2e (web-portal-e2e + admin-cms-e2e) green
  • Manual smoke notes (if any):

Security checklist

  • No new secrets / credentials in code
  • AuthN / AuthZ impact considered
  • Input validation on new endpoints
  • Audit-log entry for new state-changing operations

BRD traceability

Screenshots / output (optional)

var fieldErrors = ex.Errors.Select(e =>
{
var domainKey = e.ErrorMessage;
var domainKey = e.ErrorCode;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

explain this change

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

explain the change

Comment thread backend/AddServiceEvaluation.sql Outdated
public async Task AddAsync(ServiceEvaluation evaluation, CancellationToken ct)
{
_db.ServiceEvaluations.Add(evaluation);
await _db.SaveChangesAsync(ct).ConfigureAwait(false);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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");
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't pass static userid here

CancellationToken cancellationToken)
{
var evaluations = await _db.ServiceEvaluations
.OrderByDescending(e => e.CreatedOn)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add pagenation to this list

userId,
_clock);

await _repository.AddAsync(evaluation, cancellationToken).ConfigureAwait(false);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)." });
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// 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")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// we can keep only the version with error codes
to avoid duplicate validation execution and improve readability.

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.

2 participants