feat: add remove doctor command - #53
Conversation
|
Caution Review failedThe pull request is closed. 📝 WalkthroughWalkthroughThe pull request introduces a doctor deletion feature by adding a DELETE API endpoint, MediatR command handler, and supporting infrastructure. This includes a new Result type for consistent error handling, Identity service extensions for user disabling, domain model updates with navigation properties, and database migrations to reflect the schema changes. Changes
Sequence DiagramsequenceDiagram
participant Client
participant DoctorsController
participant Mediator
participant DeleteDoctorCommandHandler
participant BookingDbContext
participant IdentityService
participant Database
Client->>DoctorsController: DELETE /api/doctors/{id}
DoctorsController->>Mediator: Send(DeleteDoctorCommand)
Mediator->>DeleteDoctorCommandHandler: Handle(command)
DeleteDoctorCommandHandler->>BookingDbContext: Load Doctor with Appointments
BookingDbContext->>Database: Query Doctor & Appointments
Database-->>BookingDbContext: Doctor entity
BookingDbContext-->>DeleteDoctorCommandHandler: Doctor data
alt Doctor not found
DeleteDoctorCommandHandler-->>Mediator: NotFoundException
else Active future appointments exist
DeleteDoctorCommandHandler-->>Mediator: Exception
else Clear to proceed
DeleteDoctorCommandHandler->>IdentityService: DisableUserAsync(userId)
IdentityService->>Database: Set lockout + Update security stamp
Database-->>IdentityService: Success/Failure
IdentityService-->>DeleteDoctorCommandHandler: Result
alt User disable failed
DeleteDoctorCommandHandler-->>Mediator: Exception with errors
else User disabled successfully
DeleteDoctorCommandHandler->>BookingDbContext: Deactivate doctor + SaveChangesAsync()
BookingDbContext->>Database: Update Doctor.IsActive = false
Database-->>BookingDbContext: Confirmation
BookingDbContext-->>DeleteDoctorCommandHandler: Complete
DeleteDoctorCommandHandler-->>Mediator: Success
end
end
Mediator-->>DoctorsController: Result
DoctorsController-->>Client: 204 No Content / 404 / 400
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
|
Note Unit test generation is a public access feature. Expect some limitations and changes as we gather feedback and continue to improve it. Generating unit tests... This may take up to 20 minutes. |
|
No files have been changed in this PR. Unable to generate unit tests. |
|



Summary by CodeRabbit
Release Notes
New Features
Chores