Day 12 implementation - Complete CRUD operations with tenant isolation and SignalR integration.
**Domain Layer**:
- Added TenantId value object for strong typing
- Updated Project entity to include TenantId field
- Modified Project.Create factory method to require tenantId parameter
- Updated ProjectCreatedEvent to include TenantId
**Application Layer**:
- Created UpdateProjectCommand, Handler, and Validator for project updates
- Created ArchiveProjectCommand, Handler, and Validator for archiving projects
- Updated CreateProjectCommand to include TenantId
- Modified CreateProjectCommandValidator to remove OwnerId validation (set from JWT)
- Created IProjectNotificationService interface for SignalR abstraction
- Implemented ProjectCreatedEventHandler with SignalR notifications
- Implemented ProjectUpdatedEventHandler with SignalR notifications
- Implemented ProjectArchivedEventHandler with SignalR notifications
**Infrastructure Layer**:
- Updated PMDbContext to inject IHttpContextAccessor
- Configured Global Query Filter for automatic tenant isolation
- Added TenantId property mapping in ProjectConfiguration
- Created TenantId index for query performance
**API Layer**:
- Updated ProjectsController with [Authorize] attribute
- Implemented PUT /api/v1/projects/{id} for updates
- Implemented DELETE /api/v1/projects/{id} for archiving
- Added helper methods to extract TenantId and UserId from JWT claims
- Extended IRealtimeNotificationService with Project-specific methods
- Implemented RealtimeNotificationService with tenant-aware SignalR groups
- Created ProjectNotificationServiceAdapter to bridge layers
- Registered IProjectNotificationService in Program.cs
**Features Implemented**:
- Complete CRUD operations (Create, Read, Update, Archive)
- Multi-tenant isolation via EF Core Global Query Filter
- JWT-based authorization on all endpoints
- SignalR real-time notifications for all Project events
- Clean Architecture with proper layer separation
- Domain Event pattern with MediatR
**Database Migration**:
- Migration created (not applied yet): AddTenantIdToProject
**Test Scripts**:
- Created comprehensive test scripts (test-project-simple.ps1)
- Tests cover full CRUD lifecycle and tenant isolation
**Note**: API hot reload required to apply CreateProjectCommandValidator fix.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
27 lines
787 B
C#
27 lines
787 B
C#
using FluentValidation;
|
|
|
|
namespace ColaFlow.Modules.ProjectManagement.Application.Commands.UpdateProject;
|
|
|
|
/// <summary>
|
|
/// Validator for UpdateProjectCommand
|
|
/// </summary>
|
|
public class UpdateProjectCommandValidator : AbstractValidator<UpdateProjectCommand>
|
|
{
|
|
public UpdateProjectCommandValidator()
|
|
{
|
|
RuleFor(x => x.ProjectId)
|
|
.NotEmpty()
|
|
.WithMessage("ProjectId is required");
|
|
|
|
RuleFor(x => x.Name)
|
|
.NotEmpty()
|
|
.WithMessage("Project name is required")
|
|
.MaximumLength(200)
|
|
.WithMessage("Project name cannot exceed 200 characters");
|
|
|
|
RuleFor(x => x.Description)
|
|
.MaximumLength(2000)
|
|
.WithMessage("Project description cannot exceed 2000 characters");
|
|
}
|
|
}
|