Skip to content

enhanced providers for multi step#7

Merged
frigini merged 7 commits intomasterfrom
enhanced-providers-module-for-multi-step-registration
Nov 12, 2025
Merged

enhanced providers for multi step#7
frigini merged 7 commits intomasterfrom
enhanced-providers-module-for-multi-step-registration

Conversation

@frigini
Copy link
Owner

@frigini frigini commented Nov 12, 2025

Summary by CodeRabbit

  • New Features

    • Provider lifecycle UI/API actions: complete basic info, request basic-info correction, activate, suspend, and reject providers; provider status plus suspension/rejection reasons now surfaced and emitted as integration events; admin endpoint for basic-info correction.
  • Documentation

    • Added PLAN.md, WARP.md and provider module configuration guidance.
  • Chores

    • Database migrations to add status, suspension_reason and rejection_reason; placeholder config for connection string.
  • Tests

    • New unit tests covering provider status transitions and correction flows.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 12, 2025

Warning

Rate limit exceeded

@frigini has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 10 minutes and 36 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between ab8212e and 3f2141f.

📒 Files selected for processing (2)
  • src/Modules/Providers/API/Endpoints/ProviderAdmin/RequireBasicInfoCorrectionEndpoint.cs (1 hunks)
  • src/Modules/Providers/Tests/Unit/Application/Commands/RequireBasicInfoCorrectionCommandHandlerTests.cs (1 hunks)

Walkthrough

Adds provider lifecycle states and workflows: new EProviderStatus, status/reason fields, domain transitions (complete, require-correction, activate, reactivate, suspend, reject), CQRS commands/handlers/validators, domain→integration event handlers/mappers, DTO and mapper updates, EF mappings + migrations, an admin endpoint, tests, and documentation.

Changes

Cohort / File(s) Summary
Documentation
PLAN.md, WARP.md, src/Modules/Providers/Infrastructure/CONFIGURATION.md
New high-level implementation plan (PLAN), developer guide (WARP), and provider module configuration guide.
Provider Domain: Status & Lifecycle
src/Modules/Providers/Domain/Enums/EProviderStatus.cs, src/Modules/Providers/Domain/Entities/Provider.cs
Adds EProviderStatus enum; Provider gains Status, SuspensionReason, RejectionReason, initial status and state-transition methods (CompleteBasicInfo, RequireBasicInfoCorrection, Activate, Reactivate, Suspend, Reject), validation and domain events.
CQRS Commands
src/Modules/Providers/Application/Commands/...ActivateProviderCommand.cs, .../CompleteBasicInfoCommand.cs, .../RejectProviderCommand.cs, .../SuspendProviderCommand.cs, .../RequireBasicInfoCorrectionCommand.cs
New command records modeling lifecycle transitions and the require-basic-info-correction command with actor/reason fields.
Command Handlers
src/Modules/Providers/Application/Handlers/Commands/*ActivateProviderCommandHandler.cs, .../CompleteBasicInfoCommandHandler.cs, .../RejectProviderCommandHandler.cs, .../SuspendProviderCommandHandler.cs, .../RequireBasicInfoCorrectionCommandHandler.cs
ICommandHandler implementations: repository lookup, validation, invoke domain transitions, persist updates, logging and error handling.
Validators
src/Modules/Providers/Application/Validators/RejectProviderCommandValidator.cs, .../SuspendProviderCommandValidator.cs
New FluentValidation validators enforcing ProviderId, actor length, and reason length constraints for reject and suspend commands.
API Endpoint & Request Mapping
src/Modules/Providers/API/Endpoints/ProviderAdmin/RequireBasicInfoCorrectionEndpoint.cs, src/Modules/Providers/API/Mappers/RequestMapperExtensions.cs, src/Modules/Providers/API/Endpoints/ProvidersModuleEndpoints.cs
New admin POST endpoint to require basic-info correction; request DTO→command mapper; endpoint registration added.
DTOs & Mapping
src/Modules/Providers/Application/DTOs/ProviderDto.cs, src/Modules/Providers/Application/Mappers/ProviderMapper.cs, src/Modules/Providers/Application/DTOs/Requests/RequireBasicInfoCorrectionRequest.cs
ProviderDto extended with Status, SuspensionReason, RejectionReason; mapper updated; new request DTO for correction.
Domain Events
src/Modules/Providers/Domain/Events/ProviderAwaitingVerificationDomainEvent.cs, .../ProviderActivatedDomainEvent.cs, .../ProviderBasicInfoCorrectionRequiredDomainEvent.cs
New domain events for awaiting-verification, activation, and basic-info-correction-required transitions.
Event Infrastructure & Mappers
src/Modules/Providers/Infrastructure/Events/Handlers/...ProviderAwaitingVerificationDomainEventHandler.cs, ...ProviderActivatedDomainEventHandler.cs, src/Modules/Providers/Infrastructure/Events/Mappers/ProviderEventMappers.cs
Handlers map domain events to integration events and publish via IMessageBus; mapper extensions added for new events.
Integration Events
src/Shared/Messaging/Messages/Providers/ProviderAwaitingVerificationIntegrationEvent.cs, .../ProviderActivatedIntegrationEvent.cs
New integration event records for cross-module consumption.
Persistence: EF Core Mapping & Migrations
src/Modules/Providers/Infrastructure/Persistence/Configurations/ProviderConfiguration.cs, .../Migrations/20251112144744_AddProviderStatusColumn*.cs, .../Migrations/20251112181927_AddSuspensionAndRejectionReasonColumns*.cs, ProvidersDbContextModelSnapshot.cs
EF mapping for status (string conversion + index), suspension_reason, rejection_reason; migration adds non-null status with data migration and nullable reason columns; model snapshot updated.
Config & Module Files
src/Modules/Providers/Infrastructure/appsettings.json, src/Modules/Providers/Infrastructure/CONFIGURATION.md
Placeholder appsettings and guidance to use User Secrets / environment variables; security guidance added.
Tests
src/Modules/Providers/Tests/Unit/*ProvidersModuleApiTests.cs, src/Modules/Providers/Tests/Unit/Domain/Entities/ProviderTests.cs, src/Modules/Providers/Tests/Unit/Application/Commands/RequireBasicInfoCorrectionCommandHandlerTests.cs
Tests updated for new DTO signature; extensive Provider status-transition tests added; unit tests for RequireBasicInfoCorrectionCommandHandler added.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant Admin
    participant Endpoint as API Endpoint
    participant CmdDisp as Command Dispatcher
    participant CmdHandler as Command Handler
    participant Repo as ProviderRepository
    participant Domain as ProviderAggregate
    participant DB as Persistence
    participant MessageBus
    participant EventHandler

    Admin->>Endpoint: POST /{id}/require-basic-info-correction (reason, requestedBy)
    Endpoint->>CmdDisp: Dispatch RequireBasicInfoCorrectionCommand
    CmdDisp->>CmdHandler: Handle(command)
    CmdHandler->>Repo: GetById(providerId)
    Repo-->>CmdHandler: provider
    CmdHandler->>Domain: RequireBasicInfoCorrection(reason, requestedBy)
    activate Domain
    Domain->>Domain: ValidateStatusTransition()
    Domain->>Domain: Status = PendingBasicInfo
    Domain->>Domain: Emit ProviderBasicInfoCorrectionRequiredDomainEvent
    deactivate Domain
    CmdHandler->>Repo: UpdateAsync(provider)
    Repo-->>CmdHandler: saved
    CmdHandler-->>Endpoint: Result.Success
    Note over Repo,MessageBus: Domain events are published
    Repo->>MessageBus: PublishAsync(domainEvent)
    MessageBus->>EventHandler: HandleAsync(domainEvent)
    EventHandler->>MessageBus: PublishAsync(IntegrationEvent)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Areas to focus on:

  • Provider.UpdateStatus, status-transition validation logic and domain event emission.
  • Migration SQL in AddProviderStatusColumn (data mapping correctness, default values, rollback).
  • ProviderDto constructor/signature changes and all mapper/serializer usages.
  • New endpoint mapping, request→command mapping and authorization assumptions.
  • Event handler message publishing (error handling, timestamps, Source values).
  • Tests for status transitions and RequireBasicInfoCorrectionCommandHandler coverage.

Possibly related PRs

Poem

🐇
I hopped through code and status lanes,
Left notes and events like tiny trains.
Commands I carried, tests in tow,
A carrot for each green-lit flow.
Hooray — status changed! — and off I go. 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'enhanced providers for multi step' is vague and lacks specificity. While it relates to the changeset (provider enhancements and multi-step registration), it uses non-descriptive phrasing that doesn't clearly convey what specific enhancement or feature was implemented. Clarify the title to be more specific about the main change, such as 'Add provider status transitions for multi-step registration workflow' or 'Implement provider registration state machine with status tracking'.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 91.67% which is sufficient. The required threshold is 80.00%.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 6

♻️ Duplicate comments (1)
src/Modules/Providers/Application/Handlers/Commands/ActivateProviderCommandHandler.cs (1)

50-54: Avoid exposing exception details in Result.Failure.

Same issue as in CompleteBasicInfoCommandHandler.cs: returning ex.Message can leak sensitive implementation details to API consumers.

Apply the same fix:

         catch (Exception ex)
         {
             logger.LogError(ex, "Error activating provider {ProviderId}", command.ProviderId);
-            return Result.Failure(ex.Message);
+            return Result.Failure("An error occurred while activating provider");
         }
🧹 Nitpick comments (4)
PLAN.md (1)

299-307: Optional: Consider varying task introductions.

The roadmap section uses repetitive "Task:" prefixes which slightly reduces readability. This is a minor stylistic point.

Example variation:

 ### Phase 1: Foundational Provider & Search (MVP Core)
-1.  **Task**: Enhance `Providers` module for multi-step registration.
-2.  **Task**: Build `Media, Storage & Documents` module for basic document upload.
-3.  **Task**: Build `Location Management` module for CEP lookup.
-4.  **Task**: Build `Search & Discovery` module with basic radius search (PostGIS initially, can migrate to Elasticsearch later).
-5.  **Task**: Build `Service Catalog` module.
+1.  **Enhance** `Providers` module for multi-step registration.
+2.  **Build** `Media, Storage & Documents` module for basic document upload.
+3.  **Implement** `Location Management` module for CEP lookup.
+4.  **Create** `Search & Discovery` module with basic radius search (PostGIS initially, can migrate to Elasticsearch later).
+5.  **Develop** `Service Catalog` module.

Based on static analysis hints.

src/Modules/Providers/Application/Handlers/Commands/RejectProviderCommandHandler.cs (1)

51-55: Consider sanitizing exception messages.

Returning ex.Message directly could expose internal implementation details, database schema information, or sensitive system information to clients.

Consider returning a generic error message to clients:

         catch (Exception ex)
         {
             logger.LogError(ex, "Error rejecting provider {ProviderId}", command.ProviderId);
-            return Result.Failure(ex.Message);
+            return Result.Failure("An error occurred while rejecting the provider");
         }

Note: This pattern is consistent with other command handlers in the codebase. If you decide to apply this change, consider updating all command handlers uniformly.

src/Modules/Providers/Infrastructure/Events/Mappers/ProviderEventMappers.cs (1)

77-105: Consider injecting time provider for testability.

The mappers use DateTime.UtcNow directly for timestamp fields (lines 88, 103), which makes unit testing non-deterministic. While this is consistent with existing mappers in the file (lines 25, 40), consider injecting a time provider (e.g., TimeProvider in .NET 8+) to improve testability.

This would allow deterministic testing:

public static class ProviderEventMappers
{
    // Add time provider parameter or use a static factory
    private static TimeProvider TimeProvider { get; set; } = TimeProvider.System;
    
    public static ProviderAwaitingVerificationIntegrationEvent ToIntegrationEvent(
        this ProviderAwaitingVerificationDomainEvent domainEvent)
    {
        return new ProviderAwaitingVerificationIntegrationEvent(
            Source: ModuleName,
            ProviderId: domainEvent.AggregateId,
            UserId: domainEvent.UserId,
            Name: domainEvent.Name,
            UpdatedBy: domainEvent.UpdatedBy,
            TransitionedAt: TimeProvider.GetUtcNow().DateTime
        );
    }
}

Note: This would require updating all existing mappers for consistency.

WARP.md (1)

1-548: Excellent documentation addition!

This comprehensive guide will significantly help developers understand the project architecture, development workflows, and best practices. The structure is well-organized and covers all essential aspects.

If desired, you can address the minor linting issues flagged by static analysis tools (unordered list indentation, terminology consistency), but these are cosmetic and don't affect the documentation's value.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 01ccb4f and e6a89ba.

📒 Files selected for processing (28)
  • PLAN.md (1 hunks)
  • WARP.md (1 hunks)
  • src/Modules/Providers/Application/Commands/ActivateProviderCommand.cs (1 hunks)
  • src/Modules/Providers/Application/Commands/CompleteBasicInfoCommand.cs (1 hunks)
  • src/Modules/Providers/Application/Commands/RejectProviderCommand.cs (1 hunks)
  • src/Modules/Providers/Application/Commands/SuspendProviderCommand.cs (1 hunks)
  • src/Modules/Providers/Application/DTOs/ProviderDto.cs (1 hunks)
  • src/Modules/Providers/Application/Handlers/Commands/ActivateProviderCommandHandler.cs (1 hunks)
  • src/Modules/Providers/Application/Handlers/Commands/CompleteBasicInfoCommandHandler.cs (1 hunks)
  • src/Modules/Providers/Application/Handlers/Commands/RejectProviderCommandHandler.cs (1 hunks)
  • src/Modules/Providers/Application/Handlers/Commands/SuspendProviderCommandHandler.cs (1 hunks)
  • src/Modules/Providers/Application/Mappers/ProviderMapper.cs (1 hunks)
  • src/Modules/Providers/Domain/Entities/Provider.cs (4 hunks)
  • src/Modules/Providers/Domain/Enums/EProviderStatus.cs (1 hunks)
  • src/Modules/Providers/Domain/Events/ProviderActivatedDomainEvent.cs (1 hunks)
  • src/Modules/Providers/Domain/Events/ProviderAwaitingVerificationDomainEvent.cs (1 hunks)
  • src/Modules/Providers/Infrastructure/Events/Handlers/ProviderActivatedDomainEventHandler.cs (1 hunks)
  • src/Modules/Providers/Infrastructure/Events/Handlers/ProviderAwaitingVerificationDomainEventHandler.cs (1 hunks)
  • src/Modules/Providers/Infrastructure/Events/Mappers/ProviderEventMappers.cs (1 hunks)
  • src/Modules/Providers/Infrastructure/Persistence/Configurations/ProviderConfiguration.cs (2 hunks)
  • src/Modules/Providers/Infrastructure/Persistence/Migrations/20251112144744_AddProviderStatusColumn.Designer.cs (1 hunks)
  • src/Modules/Providers/Infrastructure/Persistence/Migrations/20251112144744_AddProviderStatusColumn.cs (1 hunks)
  • src/Modules/Providers/Infrastructure/Persistence/Migrations/ProvidersDbContextModelSnapshot.cs (2 hunks)
  • src/Modules/Providers/Infrastructure/appsettings.json (1 hunks)
  • src/Modules/Providers/Tests/Unit/Application/Services/ProvidersModuleApiTests.cs (1 hunks)
  • src/Modules/Providers/Tests/Unit/Domain/Entities/ProviderTests.cs (1 hunks)
  • src/Shared/Messaging/Messages/Providers/ProviderActivatedIntegrationEvent.cs (1 hunks)
  • src/Shared/Messaging/Messages/Providers/ProviderAwaitingVerificationIntegrationEvent.cs (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (16)
src/Modules/Providers/Infrastructure/Events/Mappers/ProviderEventMappers.cs (1)
src/Modules/Providers/Tests/Infrastructure/TestInfrastructureExtensions.cs (1)
  • DateTime (76-76)
src/Modules/Providers/Domain/Enums/EProviderStatus.cs (1)
src/Shared/Constants/ApiEndpoints.cs (1)
  • Providers (35-51)
src/Modules/Providers/Application/Commands/RejectProviderCommand.cs (1)
src/Shared/Constants/ApiEndpoints.cs (1)
  • Providers (35-51)
src/Modules/Providers/Application/Handlers/Commands/RejectProviderCommandHandler.cs (4)
src/Modules/Providers/Application/Handlers/Commands/ActivateProviderCommandHandler.cs (1)
  • Task (30-55)
src/Modules/Providers/Application/Handlers/Commands/CompleteBasicInfoCommandHandler.cs (1)
  • Task (30-55)
src/Modules/Providers/Application/Handlers/Commands/SuspendProviderCommandHandler.cs (1)
  • Task (30-56)
src/Modules/Providers/Domain/Entities/Provider.cs (1)
  • Reject (455-465)
src/Modules/Providers/Application/Handlers/Commands/ActivateProviderCommandHandler.cs (4)
src/Modules/Providers/Application/Handlers/Commands/CompleteBasicInfoCommandHandler.cs (1)
  • Task (30-55)
src/Modules/Providers/Application/Handlers/Commands/RejectProviderCommandHandler.cs (1)
  • Task (30-56)
src/Modules/Providers/Application/Handlers/Commands/SuspendProviderCommandHandler.cs (1)
  • Task (30-56)
src/Modules/Providers/Domain/Entities/Provider.cs (1)
  • Activate (426-433)
src/Modules/Providers/Application/Handlers/Commands/SuspendProviderCommandHandler.cs (4)
src/Modules/Providers/Application/Handlers/Commands/ActivateProviderCommandHandler.cs (1)
  • Task (30-55)
src/Modules/Providers/Application/Handlers/Commands/CompleteBasicInfoCommandHandler.cs (1)
  • Task (30-55)
src/Modules/Providers/Application/Handlers/Commands/RejectProviderCommandHandler.cs (1)
  • Task (30-56)
src/Modules/Providers/Domain/Entities/Provider.cs (1)
  • Suspend (439-449)
src/Modules/Providers/Application/Handlers/Commands/CompleteBasicInfoCommandHandler.cs (4)
src/Modules/Providers/Application/Handlers/Commands/ActivateProviderCommandHandler.cs (1)
  • Task (30-55)
src/Modules/Providers/Application/Handlers/Commands/RejectProviderCommandHandler.cs (1)
  • Task (30-56)
src/Modules/Providers/Application/Handlers/Commands/SuspendProviderCommandHandler.cs (1)
  • Task (30-56)
src/Modules/Providers/Domain/Entities/Provider.cs (1)
  • CompleteBasicInfo (414-420)
src/Modules/Providers/Infrastructure/Events/Handlers/ProviderActivatedDomainEventHandler.cs (1)
src/Modules/Providers/Infrastructure/Events/Handlers/ProviderAwaitingVerificationDomainEventHandler.cs (1)
  • Task (27-45)
src/Modules/Providers/Infrastructure/Persistence/Migrations/20251112144744_AddProviderStatusColumn.cs (1)
src/Shared/Constants/ApiEndpoints.cs (1)
  • Providers (35-51)
src/Shared/Messaging/Messages/Providers/ProviderActivatedIntegrationEvent.cs (1)
src/Modules/Providers/Infrastructure/Events/Mappers/ProviderEventMappers.cs (1)
  • ProviderActivatedIntegrationEvent (95-105)
src/Shared/Messaging/Messages/Providers/ProviderAwaitingVerificationIntegrationEvent.cs (2)
src/Modules/Providers/Infrastructure/Events/Mappers/ProviderEventMappers.cs (1)
  • ProviderAwaitingVerificationIntegrationEvent (80-90)
src/Shared/Messaging/Messages/Providers/ProviderVerificationStatusUpdatedIntegrationEvent.cs (1)
  • ProviderVerificationStatusUpdatedIntegrationEvent (16-25)
src/Modules/Providers/Domain/Entities/Provider.cs (2)
src/Modules/Providers/Domain/Exceptions/ProviderDomainException.cs (3)
  • ProviderDomainException (12-30)
  • ProviderDomainException (18-20)
  • ProviderDomainException (27-29)
src/Shared/Domain/BaseEntity.cs (2)
  • MarkAsUpdated (17-17)
  • AddDomainEvent (15-15)
src/Modules/Providers/Infrastructure/Persistence/Migrations/20251112144744_AddProviderStatusColumn.Designer.cs (2)
src/Modules/Providers/Infrastructure/Persistence/Migrations/ProvidersDbContextModelSnapshot.cs (1)
  • DbContext (13-327)
src/Modules/Providers/Infrastructure/Persistence/Migrations/20251112144744_AddProviderStatusColumn.cs (1)
  • AddProviderStatusColumn (8-42)
src/Modules/Providers/Application/Commands/SuspendProviderCommand.cs (1)
src/Shared/Constants/ApiEndpoints.cs (1)
  • Providers (35-51)
src/Modules/Providers/Infrastructure/Events/Handlers/ProviderAwaitingVerificationDomainEventHandler.cs (1)
src/Modules/Providers/Infrastructure/Events/Handlers/ProviderActivatedDomainEventHandler.cs (1)
  • Task (27-45)
src/Modules/Providers/Tests/Unit/Domain/Entities/ProviderTests.cs (1)
src/Modules/Providers/Domain/Entities/Provider.cs (6)
  • CompleteBasicInfo (414-420)
  • Activate (426-433)
  • Suspend (439-449)
  • Reject (455-465)
  • UpdateStatus (377-408)
  • Delete (502-516)
🪛 LanguageTool
WARP.md

[uncategorized] ~237-~237: The official name of this software platform is spelled with a capital “H”.
Context: ...; 3. **Update CI/CD workflow** (`.github/workflows/pr-validation.yml`): ya...

(GITHUB)


[style] ~248-~248: This phrase is redundant (‘I’ stands for ‘interface’). Use simply “API”.
Context: ...ure/database/schemas/ 5. **Add Module API interface** inShared/Contracts/Modules/{ModuleN...

(ACRONYM_TAUTOLOGY)

PLAN.md

[style] ~299-~299: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...anagementmodule for CEP lookup. 4. **Task**: BuildSearch & Discovery` module wi...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~300-~300: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... migrate to Elasticsearch later). 5. Task: Build Service Catalog module. ###...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~306-~306: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...module with Stripe integration. 4. **Task**: Integrate subscription tier intoSe...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~307-~307: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...nto Search & Discovery ranking. 5. Task: Implement document verification logi...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~313-~313: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...` module for email notifications. 4. Task: (Future) Consider an internal chat f...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~344-~344: This is not the usual sequence for adjectives that have no special emphasis.
Context: ...hese reports. - Implementation: A new small module or an extension of the Reviews...

(EN_ADJ_ORDER)


[style] ~368-~368: Consider replacing ‘giving’ with a different word to let your writing stand out.
Context: ...by enabling platform administration and giving users a space to manage their information, la...

(GIVE_TIME_STYLE)

🪛 markdownlint-cli2 (0.18.1)
WARP.md

80-80: Unordered list indentation
Expected: 2; Actual: 4

(MD007, ul-indent)


324-324: Unordered list indentation
Expected: 2; Actual: 4

(MD007, ul-indent)


325-325: Unordered list indentation
Expected: 2; Actual: 4

(MD007, ul-indent)


326-326: Unordered list indentation
Expected: 2; Actual: 4

(MD007, ul-indent)


327-327: Unordered list indentation
Expected: 2; Actual: 4

(MD007, ul-indent)


333-333: Unordered list indentation
Expected: 2; Actual: 4

(MD007, ul-indent)


334-334: Unordered list indentation
Expected: 2; Actual: 4

(MD007, ul-indent)


335-335: Unordered list indentation
Expected: 2; Actual: 4

(MD007, ul-indent)


341-341: Unordered list indentation
Expected: 2; Actual: 4

(MD007, ul-indent)


342-342: Unordered list indentation
Expected: 2; Actual: 4

(MD007, ul-indent)


343-343: Unordered list indentation
Expected: 2; Actual: 4

(MD007, ul-indent)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Code Quality Checks
  • GitHub Check: Security Scan
🔇 Additional comments (15)
src/Modules/Providers/Tests/Unit/Application/Services/ProvidersModuleApiTests.cs (1)

233-233: LGTM! Test data updated correctly.

The test helper now includes the Status property initialized to PendingBasicInfo, which correctly aligns with the new provider lifecycle state machine introduced in this PR.

src/Modules/Providers/Infrastructure/Persistence/Migrations/ProvidersDbContextModelSnapshot.cs (1)

50-54: LGTM! Good addition of status column with appropriate indexing.

The migration correctly adds the Status property as a required string with a maximum length of 30 characters, which is appropriate for storing enum values. The inclusion of an index on the status column is a good practice that will optimize queries filtering by provider status.

Also applies to: 84-85

src/Modules/Providers/Application/Mappers/ProviderMapper.cs (1)

23-23: LGTM! Status mapping correctly integrated.

The provider.Status mapping is correctly positioned in the DTO construction, maintaining consistency with the updated ProviderDto signature. The absence of reverse mapping (ToDomain) for Status is appropriate, as provider status should be managed through domain methods rather than reconstructed from DTOs.

src/Modules/Providers/Application/DTOs/ProviderDto.cs (1)

14-14: Status property is correctly integrated in ProviderMapper.

The Status property has been properly included in the ProviderMapper.ToDto() method at line 21, positioned correctly in the constructor call. All production code paths that create ProviderDto instances use this mapper, so the new property is consistently available across all consumers. No additional updates are needed.

src/Modules/Providers/Application/Commands/RejectProviderCommand.cs (1)

12-16: The original review comment is incorrect and should be disregarded.

The optional Reason parameter in RejectProviderCommand is intentional and consistent with the codebase architecture. The SuspendProviderCommand uses the identical pattern, with optional Reason that is logged but not enforced. Domain entities accept only the actor identifier (RejectedBy/SuspendedBy), not the reason. No validators enforce the reason as mandatory, and other administrative commands follow the same optional audit field pattern (e.g., UpdatedBy, DeletedBy). The reason is captured for logging/audit purposes, not strict enforcement, which is the established design in this codebase.

Likely an incorrect or invalid review comment.

src/Modules/Providers/Domain/Events/ProviderActivatedDomainEvent.cs (1)

1-25: LGTM!

The domain event is well-structured with comprehensive XML documentation. The properties appropriately capture the provider activation context, and the record inherits correctly from DomainEvent.

src/Modules/Providers/Application/Commands/CompleteBasicInfoCommand.cs (1)

1-15: LGTM!

The command structure is clean, well-documented, and consistent with other commands in the module like ActivateProviderCommand and SuspendProviderCommand.

src/Modules/Providers/Infrastructure/Persistence/Configurations/ProviderConfiguration.cs (1)

37-43: LGTM!

The Status property configuration follows the established pattern for enum mappings (consistent with Type and VerificationStatus). The index naming follows the convention used for other indexes in the configuration.

Also applies to: 218-219

src/Modules/Providers/Application/Commands/ActivateProviderCommand.cs (1)

1-14: LGTM!

The command is well-documented and follows the same pattern as other lifecycle commands in the module.

src/Modules/Providers/Tests/Unit/Domain/Entities/ProviderTests.cs (1)

401-610: LGTM! Excellent test coverage.

The status transition tests are comprehensive and well-structured:

  • Initialization: Validates default PendingBasicInfo status
  • Valid transitions: Covers all happy path transitions with domain event verification
  • Invalid transitions: Ensures exceptions are thrown for disallowed transitions
  • Edge cases: Tests idempotency (already suspended) and constraints (deleted provider)
  • Data-driven tests: Theory test at lines 554-608 systematically validates multiple transition rules

The tests follow the AAA pattern consistently and have descriptive names. This provides strong protection against regressions in the status lifecycle.

src/Modules/Providers/Domain/Enums/EProviderStatus.cs (1)

1-47: Verify whether Status filtering endpoints are needed based on your business requirements.

The enum is well-structured with clear documentation. However, the suggestion to consider a GetByStatus endpoint is valid: the Status field is now indexed in the database and represents a distinct workflow from VerificationStatus, yet no corresponding query method exists in the repository.

Check whether any clients or internal services need to query providers by their registration status (PendingBasicInfo, PendingDocumentVerification, Active, Suspended, or Rejected). If filtering by Status is a required feature, you'll need to add:

  • A GetByStatusAsync method to IProviderRepository
  • A corresponding query handler and API endpoint
  • Update ApiEndpoints.cs to include the new endpoint
src/Shared/Messaging/Messages/Providers/ProviderActivatedIntegrationEvent.cs (1)

17-24: LGTM!

The integration event is well-structured and follows the established pattern. The documentation clearly explains its purpose and the optional parameters are appropriate for this use case.

src/Shared/Messaging/Messages/Providers/ProviderAwaitingVerificationIntegrationEvent.cs (1)

17-24: LGTM!

The integration event follows the established pattern and is well-documented. The structure is consistent with ProviderActivatedIntegrationEvent and other integration events in the codebase.

src/Modules/Providers/Domain/Events/ProviderAwaitingVerificationDomainEvent.cs (1)

19-25: LGTM!

The domain event is properly structured with appropriate documentation. It follows DDD best practices and carries the necessary context for the state transition.

src/Modules/Providers/Infrastructure/Events/Handlers/ProviderActivatedDomainEventHandler.cs (1)

27-45: LGTM!

The event handler is well-implemented with proper error handling. The catch-and-rethrow pattern is appropriate here as it logs the error before propagating it to the domain event dispatcher. The use of the mapper extension method keeps the code clean and maintainable.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e6a89ba and 4ae165a.

📒 Files selected for processing (20)
  • src/Modules/Providers/Application/Commands/RejectProviderCommand.cs (1 hunks)
  • src/Modules/Providers/Application/Commands/SuspendProviderCommand.cs (1 hunks)
  • src/Modules/Providers/Application/DTOs/ProviderDto.cs (1 hunks)
  • src/Modules/Providers/Application/Handlers/Commands/ActivateProviderCommandHandler.cs (1 hunks)
  • src/Modules/Providers/Application/Handlers/Commands/CompleteBasicInfoCommandHandler.cs (1 hunks)
  • src/Modules/Providers/Application/Handlers/Commands/RejectProviderCommandHandler.cs (1 hunks)
  • src/Modules/Providers/Application/Handlers/Commands/SuspendProviderCommandHandler.cs (1 hunks)
  • src/Modules/Providers/Application/Mappers/ProviderMapper.cs (1 hunks)
  • src/Modules/Providers/Application/Validators/RejectProviderCommandValidator.cs (1 hunks)
  • src/Modules/Providers/Application/Validators/SuspendProviderCommandValidator.cs (1 hunks)
  • src/Modules/Providers/Domain/Entities/Provider.cs (5 hunks)
  • src/Modules/Providers/Infrastructure/CONFIGURATION.md (1 hunks)
  • src/Modules/Providers/Infrastructure/Persistence/Configurations/ProviderConfiguration.cs (3 hunks)
  • src/Modules/Providers/Infrastructure/Persistence/Migrations/20251112144744_AddProviderStatusColumn.cs (1 hunks)
  • src/Modules/Providers/Infrastructure/Persistence/Migrations/20251112181927_AddSuspensionAndRejectionReasonColumns.Designer.cs (1 hunks)
  • src/Modules/Providers/Infrastructure/Persistence/Migrations/20251112181927_AddSuspensionAndRejectionReasonColumns.cs (1 hunks)
  • src/Modules/Providers/Infrastructure/Persistence/Migrations/ProvidersDbContextModelSnapshot.cs (2 hunks)
  • src/Modules/Providers/Infrastructure/appsettings.json (1 hunks)
  • src/Modules/Providers/Tests/Unit/Application/Services/ProvidersModuleApiTests.cs (2 hunks)
  • src/Modules/Providers/Tests/Unit/Domain/Entities/ProviderTests.cs (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • src/Modules/Providers/Infrastructure/CONFIGURATION.md
🚧 Files skipped from review as they are similar to previous changes (6)
  • src/Modules/Providers/Infrastructure/Persistence/Configurations/ProviderConfiguration.cs
  • src/Modules/Providers/Tests/Unit/Domain/Entities/ProviderTests.cs
  • src/Modules/Providers/Application/Handlers/Commands/ActivateProviderCommandHandler.cs
  • src/Modules/Providers/Infrastructure/appsettings.json
  • src/Modules/Providers/Application/DTOs/ProviderDto.cs
  • src/Modules/Providers/Infrastructure/Persistence/Migrations/ProvidersDbContextModelSnapshot.cs
🧰 Additional context used
🧬 Code graph analysis (10)
src/Modules/Providers/Application/Handlers/Commands/RejectProviderCommandHandler.cs (3)
src/Modules/Providers/Application/Handlers/Commands/ActivateProviderCommandHandler.cs (1)
  • Task (30-55)
src/Modules/Providers/Application/Handlers/Commands/SuspendProviderCommandHandler.cs (1)
  • Task (30-68)
src/Modules/Providers/Domain/Entities/Provider.cs (1)
  • Reject (471-485)
src/Modules/Providers/Application/Validators/RejectProviderCommandValidator.cs (1)
src/Shared/Constants/ApiEndpoints.cs (1)
  • Providers (35-51)
src/Modules/Providers/Infrastructure/Persistence/Migrations/20251112181927_AddSuspensionAndRejectionReasonColumns.cs (1)
src/Modules/Providers/Infrastructure/Persistence/Migrations/20251112144744_AddProviderStatusColumn.cs (2)
  • Up (11-40)
  • Down (43-54)
src/Modules/Providers/Infrastructure/Persistence/Migrations/20251112144744_AddProviderStatusColumn.cs (1)
src/Modules/Providers/Infrastructure/Persistence/Migrations/20251112181927_AddSuspensionAndRejectionReasonColumns.cs (2)
  • Up (11-28)
  • Down (31-42)
src/Modules/Providers/Application/Handlers/Commands/CompleteBasicInfoCommandHandler.cs (2)
src/Modules/Providers/Application/Handlers/Commands/ActivateProviderCommandHandler.cs (1)
  • Task (30-55)
src/Modules/Providers/Domain/Entities/Provider.cs (1)
  • CompleteBasicInfo (424-430)
src/Modules/Providers/Application/Commands/SuspendProviderCommand.cs (1)
src/Shared/Constants/ApiEndpoints.cs (1)
  • Providers (35-51)
src/Modules/Providers/Domain/Entities/Provider.cs (2)
src/Modules/Providers/Domain/Exceptions/ProviderDomainException.cs (3)
  • ProviderDomainException (12-30)
  • ProviderDomainException (18-20)
  • ProviderDomainException (27-29)
src/Shared/Domain/BaseEntity.cs (2)
  • MarkAsUpdated (17-17)
  • AddDomainEvent (15-15)
src/Modules/Providers/Infrastructure/Persistence/Migrations/20251112181927_AddSuspensionAndRejectionReasonColumns.Designer.cs (3)
src/Modules/Providers/Infrastructure/Persistence/Migrations/ProvidersDbContextModelSnapshot.cs (1)
  • DbContext (13-337)
src/Modules/Providers/Infrastructure/Persistence/Migrations/20251112181927_AddSuspensionAndRejectionReasonColumns.cs (1)
  • AddSuspensionAndRejectionReasonColumns (8-43)
src/Modules/Providers/Infrastructure/Persistence/Migrations/20251031190904_InitialCreate.Designer.cs (1)
  • MeAjudaAi (12-307)
src/Modules/Providers/Application/Commands/RejectProviderCommand.cs (1)
src/Shared/Constants/ApiEndpoints.cs (1)
  • Providers (35-51)
src/Modules/Providers/Application/Handlers/Commands/SuspendProviderCommandHandler.cs (2)
src/Modules/Providers/Application/Handlers/Commands/RejectProviderCommandHandler.cs (1)
  • Task (30-68)
src/Modules/Providers/Domain/Entities/Provider.cs (1)
  • Suspend (450-464)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Code Quality Checks
  • GitHub Check: Security Scan
🔇 Additional comments (1)
src/Modules/Providers/Application/Handlers/Commands/RejectProviderCommandHandler.cs (1)

56-57: Reason now reaches the aggregate

Good to see command.Reason flowing into provider.Reject, ensuring the audit detail lands on the entity and persists.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
src/Modules/Providers/Domain/Entities/Provider.cs (2)

433-444: LGTM: Activate correctly transitions and updates verification status.

The method properly guards the precondition, transitions to Active, and synchronizes VerificationStatus. The logic is sound.

Minor note: Both UpdateStatus and UpdateVerificationStatus call MarkAsUpdated(), setting UpdatedAt twice. Not a functional issue, but a small inefficiency. The same pattern appears in Suspend (line 463-464) and Reject (line 484-485).


514-537: LGTM: Status transition validation is well-structured.

The state machine is clearly defined and validates allowed transitions. The logic correctly handles same-status "transitions" and throws for invalid transitions.

Minor observation: The transition from PendingDocumentVerification back to PendingBasicInfo (line 526) is defined but no method in this entity uses it. If this is for future use, consider adding a TODO comment; otherwise, consider removing it to keep the transition table minimal.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4ae165a and e10dcdb.

📒 Files selected for processing (1)
  • src/Modules/Providers/Domain/Entities/Provider.cs (6 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/Modules/Providers/Domain/Entities/Provider.cs (2)
src/Modules/Providers/Domain/Exceptions/ProviderDomainException.cs (3)
  • ProviderDomainException (12-30)
  • ProviderDomainException (18-20)
  • ProviderDomainException (27-29)
src/Shared/Domain/BaseEntity.cs (2)
  • MarkAsUpdated (17-17)
  • AddDomainEvent (15-15)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Code Quality Checks
  • GitHub Check: Security Scan
🔇 Additional comments (6)
src/Modules/Providers/Domain/Entities/Provider.cs (6)

50-56: LGTM: Status property properly encapsulated.

The Status property follows proper domain entity encapsulation with a private setter and clear documentation.


85-93: LGTM: Reason fields properly defined.

The nullable reason fields with clear documentation align with the domain requirements. The Suspend/Reject methods enforce the required constraints at runtime.


120-120: LGTM: Consistent Status initialization.

Both constructors correctly initialize new providers to PendingBasicInfo status, establishing the proper starting state for the multi-step registration workflow.

Also applies to: 153-153


421-431: LGTM: CompleteBasicInfo correctly guards and transitions.

The method properly validates preconditions and delegates to UpdateStatus for the state transition. The guard ensures it can only advance from PendingBasicInfo.


446-465: LGTM: Suspend correctly manages reason and state transitions.

The method properly validates the required reason, sets SuspensionReason before calling UpdateStatus, and synchronizes VerificationStatus. The order ensures ClearReasonFieldsIfNeeded won't clear the reason since the new status IS Suspended.


539-556: LGTM: Reason fields correctly cleared on state transitions.

This method properly implements the invariant that SuspensionReason and RejectionReason are only valid while in their respective states. The logic correctly clears each reason when leaving that state and preserves them when in that state.

This addresses the previous review concern about resetting suspension/rejection reasons when transitioning away from those states. The implementation is called at the correct point in UpdateStatus (line 398): after the status change and MarkAsUpdated(), but before emitting domain events.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/Modules/Providers/Domain/Entities/Provider.cs (1)

520-544: Address TODO: Implement public method for document correction flow.

The transition matrix (line 533) already allows PendingDocumentVerificationPendingBasicInfo, but the TODO comment indicates a public method is needed to encapsulate this business operation.

Would you like me to implement the missing method? Example:

+/// <summary>
+/// Retorna o prestador para correção de informações básicas.
+/// </summary>
+/// <param name="reason">Motivo da correção necessária</param>
+/// <param name="updatedBy">Quem está solicitando a correção</param>
+public void RequireBasicInfoCorrection(string reason, string? updatedBy = null)
+{
+    if (Status != EProviderStatus.PendingDocumentVerification)
+        throw new ProviderDomainException("Can only require corrections during document verification");
+
+    if (string.IsNullOrWhiteSpace(reason))
+        throw new ProviderDomainException("Correction reason is required");
+
+    UpdateStatus(EProviderStatus.PendingBasicInfo, updatedBy);
+    
+    // Optionally emit a domain event for this transition
+    AddDomainEvent(new ProviderBasicInfoCorrectionRequiredDomainEvent(
+        Id.Value, 1, UserId, Name, reason, updatedBy));
+}

Should I open a new issue to track this task?

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e10dcdb and 03a50e5.

📒 Files selected for processing (1)
  • src/Modules/Providers/Domain/Entities/Provider.cs (7 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/Modules/Providers/Domain/Entities/Provider.cs (2)
src/Modules/Providers/Domain/Exceptions/ProviderDomainException.cs (3)
  • ProviderDomainException (12-30)
  • ProviderDomainException (18-20)
  • ProviderDomainException (27-29)
src/Shared/Domain/BaseEntity.cs (2)
  • MarkAsUpdated (17-17)
  • AddDomainEvent (15-15)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Code Quality Checks
  • GitHub Check: Security Scan
🔇 Additional comments (10)
src/Modules/Providers/Domain/Entities/Provider.cs (10)

50-56: LGTM!

The Status property is well-documented and correctly encapsulates the multi-step registration state with appropriate access control.


85-93: LGTM!

The reason properties are appropriately nullable and well-documented, clearly indicating their conditional nature based on provider status.


120-120: LGTM!

Correct initialization of Status to PendingBasicInfo for new provider instances.


361-379: LGTM!

The skipMarkAsUpdated parameter is a sensible optimization to prevent redundant timestamp updates when this method is called alongside UpdateStatus.


427-437: LGTM!

Well-encapsulated business method with appropriate precondition validation.


452-471: Verify idempotent behavior for suspension reason updates.

The early return at lines 462-463 prevents updating the suspension reason if the provider is already suspended. While this implements idempotency, it means:

  • Calling Suspend("Reason A") followed by Suspend("Reason B") leaves the reason as "Reason A"
  • The suspension reason cannot be updated without first reactivating the provider

Is this the intended behavior, or should there be a way to update the suspension reason while remaining suspended?


473-492: Verify idempotent behavior for rejection reason updates.

Similar to Suspend, the early return at lines 483-484 prevents updating the rejection reason if already rejected. This means the rejection reason cannot be modified without reopening and re-rejecting the registration.

Is this the intended behavior?


546-563: LGTM!

This method correctly implements the invariant that reason fields only exist while in their corresponding states, addressing the previous review concern. The logic properly clears stale reasons when transitioning away from Suspended or Rejected states.


565-580: LGTM!

This method correctly enforces the invariant that SuspensionReason and RejectionReason must be set before transitioning to their respective states, addressing the previous review concern. The validation integrates properly with the Suspend and Reject methods which set reasons before calling UpdateStatus.


381-425: Clarify event coverage for provider status transitions.

The implementation correctly covers the registration flow (PendingBasicInfo → DocumentVerification → Active) with specific domain events. However, there are legitimate gaps:

  1. Verified gap: Transitions OUT of Suspended/Rejected states lack events entirely:

    • SuspendedActive (reactivation): No event emitted
    • RejectedPendingBasicInfo (reopening): No event emitted
  2. Noted: Transitions INTO Suspended/Rejected ARE covered via ProviderVerificationStatusUpdatedDomainEvent in the UpdateVerificationStatus() method (line 373), so audit trail exists for suspension/rejection actions.

Should reactivation and reopening transitions emit explicit status-change events for cross-module coordination (e.g., notification services, audit logs)?

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (2)
src/Modules/Providers/Application/Handlers/Commands/RequireBasicInfoCorrectionCommandHandler.cs (1)

68-72: Preserve domain validation message

Catching every exception and replying with “Failed to require basic info correction” hides actionable domain feedback. When Provider.RequireBasicInfoCorrection rejects the transition (e.g., status ≠ PendingDocumentVerification) the admin gets no clue. Catch the domain/functional exception separately and return its message, reserving the generic text for unexpected failures.

src/Modules/Providers/Tests/Unit/Application/Commands/RequireBasicInfoCorrectionCommandHandlerTests.cs (1)

296-299: Prefer type-safe event assertion over string comparison.

The domain event check uses GetType().Name string comparison, which is fragile. If the event type is renamed or moved, the test will pass incorrectly.

Apply this diff to use type-safe assertion:

-        provider.DomainEvents.Should().Contain(e => 
-            e.GetType().Name == "ProviderBasicInfoCorrectionRequiredDomainEvent");
+        var correctionEvent = provider.DomainEvents
+            .OfType<ProviderBasicInfoCorrectionRequiredDomainEvent>()
+            .Should().ContainSingle().Subject;
+        correctionEvent.Reason.Should().Be("Contact information needs verification");

Add the using statement at the top:

+using MeAjudaAi.Modules.Providers.Domain.Events;
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 03a50e5 and 286bf77.

📒 Files selected for processing (10)
  • src/Modules/Providers/API/Endpoints/ProviderAdmin/RequireBasicInfoCorrectionEndpoint.cs (1 hunks)
  • src/Modules/Providers/API/Endpoints/ProvidersModuleEndpoints.cs (1 hunks)
  • src/Modules/Providers/API/Mappers/RequestMapperExtensions.cs (1 hunks)
  • src/Modules/Providers/Application/Commands/RequireBasicInfoCorrectionCommand.cs (1 hunks)
  • src/Modules/Providers/Application/DTOs/Requests/RequireBasicInfoCorrectionRequest.cs (1 hunks)
  • src/Modules/Providers/Application/Handlers/Commands/RequireBasicInfoCorrectionCommandHandler.cs (1 hunks)
  • src/Modules/Providers/Domain/Entities/Provider.cs (7 hunks)
  • src/Modules/Providers/Domain/Events/ProviderBasicInfoCorrectionRequiredDomainEvent.cs (1 hunks)
  • src/Modules/Providers/Tests/Unit/Application/Commands/RequireBasicInfoCorrectionCommandHandlerTests.cs (1 hunks)
  • src/Modules/Providers/Tests/Unit/Domain/Entities/ProviderTests.cs (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (7)
src/Modules/Providers/API/Endpoints/ProvidersModuleEndpoints.cs (1)
src/Modules/Providers/API/Endpoints/ProviderAdmin/RequireBasicInfoCorrectionEndpoint.cs (1)
  • RequireBasicInfoCorrectionEndpoint (22-115)
src/Modules/Providers/API/Endpoints/ProviderAdmin/RequireBasicInfoCorrectionEndpoint.cs (3)
src/Shared/Endpoints/BaseEndpoint.cs (1)
  • BaseEndpoint (10-130)
src/Modules/Providers/Application/Handlers/Commands/RequireBasicInfoCorrectionCommandHandler.cs (1)
  • Task (31-73)
src/Modules/Providers/API/Mappers/RequestMapperExtensions.cs (1)
  • RequireBasicInfoCorrectionCommand (83-90)
src/Modules/Providers/Application/Handlers/Commands/RequireBasicInfoCorrectionCommandHandler.cs (3)
src/Modules/Providers/API/Mappers/RequestMapperExtensions.cs (1)
  • RequireBasicInfoCorrectionCommand (83-90)
src/Modules/Providers/API/Endpoints/ProviderAdmin/RequireBasicInfoCorrectionEndpoint.cs (1)
  • Task (100-114)
src/Modules/Providers/Domain/Entities/Provider.cs (1)
  • RequireBasicInfoCorrection (444-461)
src/Modules/Providers/Application/Commands/RequireBasicInfoCorrectionCommand.cs (1)
src/Modules/Providers/API/Mappers/RequestMapperExtensions.cs (1)
  • RequireBasicInfoCorrectionCommand (83-90)
src/Modules/Providers/Tests/Unit/Application/Commands/RequireBasicInfoCorrectionCommandHandlerTests.cs (4)
src/Modules/Providers/Application/Handlers/Commands/RequireBasicInfoCorrectionCommandHandler.cs (2)
  • RequireBasicInfoCorrectionCommandHandler (20-74)
  • Task (31-73)
src/Modules/Providers/Tests/Unit/Domain/Entities/ProviderTests.cs (6)
  • Provider (391-399)
  • Theory (94-111)
  • Theory (586-660)
  • Theory (679-712)
  • Theory (730-765)
  • Theory (767-783)
src/Modules/Providers/Domain/Entities/Provider.cs (8)
  • CompleteBasicInfo (431-437)
  • Provider (19-635)
  • Provider (98-98)
  • Provider (103-124)
  • Provider (137-163)
  • Activate (467-474)
  • Suspend (494-508)
  • Reject (515-529)
src/Modules/Providers/API/Mappers/RequestMapperExtensions.cs (1)
  • RequireBasicInfoCorrectionCommand (83-90)
src/Modules/Providers/Tests/Unit/Domain/Entities/ProviderTests.cs (2)
src/Modules/Providers/Domain/Entities/Provider.cs (8)
  • CompleteBasicInfo (431-437)
  • Activate (467-474)
  • Suspend (494-508)
  • Reject (515-529)
  • UpdateStatus (390-425)
  • Delete (541-555)
  • Reactivate (480-487)
  • RequireBasicInfoCorrection (444-461)
src/Modules/Providers/Tests/Infrastructure/TestInfrastructureExtensions.cs (1)
  • DateTime (76-76)
src/Modules/Providers/Domain/Entities/Provider.cs (2)
src/Modules/Providers/Domain/Exceptions/ProviderDomainException.cs (3)
  • ProviderDomainException (12-30)
  • ProviderDomainException (18-20)
  • ProviderDomainException (27-29)
src/Shared/Domain/BaseEntity.cs (2)
  • MarkAsUpdated (17-17)
  • AddDomainEvent (15-15)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Code Quality Checks
  • GitHub Check: Security Scan
🔇 Additional comments (6)
src/Modules/Providers/API/Endpoints/ProvidersModuleEndpoints.cs (1)

49-62: RequireBasicInfoCorrection endpoint registration LGTM

Registration fits the existing fluent chain and keeps the module wiring consistent.

src/Modules/Providers/Application/Commands/RequireBasicInfoCorrectionCommand.cs (1)

13-17: Command contract reads clean

Definition mirrors the workflow and stays aligned with the command pattern in this module.

src/Modules/Providers/Domain/Events/ProviderBasicInfoCorrectionRequiredDomainEvent.cs (1)

21-28: Domain event payload looks comprehensive

Includes the identifiers and rationale needed for auditing when the workflow reverts to PendingBasicInfo.

src/Modules/Providers/Tests/Unit/Domain/Entities/ProviderTests.cs (1)

401-785: LGTM! Comprehensive status transition test coverage.

The new status transition tests provide excellent coverage of the multi-step provider registration workflow, including:

  • All valid state transitions with proper event emission
  • Guard conditions preventing invalid transitions
  • Required field validation (reasons for suspension/rejection)
  • Edge cases like idempotent operations

The test organization using the Theory pattern for parameterized testing is particularly effective.

src/Modules/Providers/API/Endpoints/ProviderAdmin/RequireBasicInfoCorrectionEndpoint.cs (1)

14-77: LGTM! Outstanding API documentation and proper authorization.

The OpenAPI documentation is exceptionally comprehensive, providing:

  • Clear use cases for when to use the endpoint
  • Step-by-step workflow after correction
  • Field-level validation rules
  • Security restrictions with AdminOnly authorization

The implementation correctly validates the request body and follows the established CQRS pattern.

src/Modules/Providers/Domain/Entities/Provider.cs (1)

381-616: LGTM! Solid state machine implementation with proper invariant enforcement.

The status management implementation addresses all past review concerns:

Reason field clearing (lines 590-599): ClearReasonFieldsIfNeeded properly clears SuspensionReason and RejectionReason when transitioning away from those states.

Invariant validation (lines 609-616): ValidateRequiredReasons enforces that reason fields must be set before transitioning to Suspended or Rejected states.

Reactivation support (lines 476-487): Reactivate method handles the SuspendedActive transition with proper verification status update.

The state machine is well-designed with:

  • Comprehensive transition validation using an allowed transitions dictionary
  • Proper encapsulation with private setters on status and reason fields
  • Domain events for key lifecycle transitions
  • Coordinated updates between Status and VerificationStatus

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/Modules/Providers/Tests/Unit/Application/Commands/RequireBasicInfoCorrectionCommandHandlerTests.cs (1)

119-151: Tighten assertions around persistence.

When validation fails we should assert that IProviderRepository.UpdateAsync was never invoked, just like we already ensure GetByIdAsync isn’t called. That keeps future regressions from sneaking in a persistence call on invalid payloads.

         _providerRepositoryMock.Verify(
             r => r.GetByIdAsync(It.IsAny<ProviderId>(), It.IsAny<CancellationToken>()),
             Times.Never);
+
+        _providerRepositoryMock.Verify(
+            r => r.UpdateAsync(It.IsAny<Provider>(), It.IsAny<CancellationToken>()),
+            Times.Never);

Mirror the same assertion in the invalidRequestedBy test as well.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 286bf77 and ab8212e.

📒 Files selected for processing (5)
  • src/Modules/Providers/API/Endpoints/ProviderAdmin/RequireBasicInfoCorrectionEndpoint.cs (1 hunks)
  • src/Modules/Providers/API/Mappers/RequestMapperExtensions.cs (1 hunks)
  • src/Modules/Providers/Application/DTOs/Requests/RequireBasicInfoCorrectionRequest.cs (1 hunks)
  • src/Modules/Providers/Application/Handlers/Commands/RequireBasicInfoCorrectionCommandHandler.cs (1 hunks)
  • src/Modules/Providers/Tests/Unit/Application/Commands/RequireBasicInfoCorrectionCommandHandlerTests.cs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/Modules/Providers/Application/DTOs/Requests/RequireBasicInfoCorrectionRequest.cs
  • src/Modules/Providers/API/Mappers/RequestMapperExtensions.cs
🧰 Additional context used
🧬 Code graph analysis (3)
src/Modules/Providers/API/Endpoints/ProviderAdmin/RequireBasicInfoCorrectionEndpoint.cs (3)
src/Shared/Endpoints/BaseEndpoint.cs (1)
  • BaseEndpoint (10-130)
src/Modules/Providers/Application/Handlers/Commands/RequireBasicInfoCorrectionCommandHandler.cs (1)
  • Task (32-83)
src/Modules/Providers/API/Mappers/RequestMapperExtensions.cs (1)
  • RequireBasicInfoCorrectionCommand (84-91)
src/Modules/Providers/Tests/Unit/Application/Commands/RequireBasicInfoCorrectionCommandHandlerTests.cs (5)
src/Modules/Providers/Application/Handlers/Commands/RequireBasicInfoCorrectionCommandHandler.cs (2)
  • RequireBasicInfoCorrectionCommandHandler (21-84)
  • Task (32-83)
src/Modules/Providers/Tests/Unit/Domain/Entities/ProviderTests.cs (6)
  • Provider (391-399)
  • Theory (94-111)
  • Theory (586-660)
  • Theory (679-712)
  • Theory (730-765)
  • Theory (767-783)
src/Modules/Providers/API/Endpoints/ProviderAdmin/RequireBasicInfoCorrectionEndpoint.cs (1)
  • Task (103-124)
src/Modules/Providers/Domain/Entities/Provider.cs (8)
  • CompleteBasicInfo (431-437)
  • Provider (19-635)
  • Provider (98-98)
  • Provider (103-124)
  • Provider (137-163)
  • Activate (467-474)
  • Suspend (494-508)
  • Reject (515-529)
src/Modules/Providers/API/Mappers/RequestMapperExtensions.cs (1)
  • RequireBasicInfoCorrectionCommand (84-91)
src/Modules/Providers/Application/Handlers/Commands/RequireBasicInfoCorrectionCommandHandler.cs (3)
src/Modules/Providers/API/Mappers/RequestMapperExtensions.cs (1)
  • RequireBasicInfoCorrectionCommand (84-91)
src/Modules/Providers/API/Endpoints/ProviderAdmin/RequireBasicInfoCorrectionEndpoint.cs (1)
  • Task (103-124)
src/Modules/Providers/Domain/Entities/Provider.cs (1)
  • RequireBasicInfoCorrection (444-461)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Code Quality Checks
  • GitHub Check: Security Scan
🔇 Additional comments (1)
src/Modules/Providers/Application/Handlers/Commands/RequireBasicInfoCorrectionCommandHandler.cs (1)

40-50: Good early validation on command payload.

These guard clauses stop us from touching the repository when the client payload is incomplete, keeping the failure cheap and predictable. Nicely done.

@github-actions
Copy link

📊 Code Coverage Report

Coverage: 40.76% (extracted from OpenCover (Direct))

📈 Coverage Details

  • Coverage badges: Coverage
  • Minimum threshold: 70% (warning) / 85% (good)
  • Report format: Auto-detected from OpenCover/Cobertura XML files
  • Coverage source: OpenCover (Direct)

📋 Coverage Analysis

  • Line Coverage: Shows percentage of code lines executed during tests
  • Branch Coverage: Shows percentage of code branches/conditions tested
  • Complexity: Code complexity metrics for maintainability

🎯 Quality Gates

  • Pass: Coverage ≥ 85%
  • ⚠️ Warning: Coverage 70-84%
  • Fail: Coverage < 70%

📁 Artifacts

  • Coverage reports: Available in workflow artifacts
  • Test results: TRX files with detailed test execution data

This comment is updated automatically on each push to track coverage trends.

@frigini frigini merged commit 505284f into master Nov 12, 2025
6 checks passed
@frigini frigini deleted the enhanced-providers-module-for-multi-step-registration branch November 12, 2025 20:00
frigini pushed a commit that referenced this pull request Nov 21, 2025
New test failing due to SetAllowUnauthenticated(true):
- ApiVersioning_ShouldWork_ForDifferentModules
- Expected: OK/401/400
- Actual: 403 Forbidden

Same root cause as PermissionAuthorizationE2ETests.
All authentication-dependent tests require handler refactor in Sprint 1.

Updated: 96/103 passing, 7 skipped (93.2% success rate)
This was referenced Nov 28, 2025
frigini pushed a commit that referenced this pull request Dec 18, 2025
- Move Infrastructure/Migrations para Infrastructure/Persistence/Migrations
- Atualiza namespaces em todas as migrations e snapshots
- Melhora organização: migrations agora próximas ao DbContext
- Mantém histórico git com git mv

Item #7 concluído
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.

1 participant