Files
ColaFlow/colaflow-api/src/Modules/ProjectManagement/ColaFlow.Modules.ProjectManagement.Application/EventHandlers/TaskAssignedEventHandler.cs
Yaojia Wang b53521775c feat(signalr): Add real-time notifications for Epic/Story/Task operations
Extends SignalR notification system to cover all ProjectManagement CRUD operations:

Domain Events Created:
- EpicUpdatedEvent, EpicDeletedEvent
- StoryCreatedEvent, StoryUpdatedEvent, StoryDeletedEvent
- TaskCreatedEvent, TaskUpdatedEvent, TaskDeletedEvent, TaskAssignedEvent

Event Handlers Added (10 handlers):
- EpicCreatedEventHandler, EpicUpdatedEventHandler, EpicDeletedEventHandler
- StoryCreatedEventHandler, StoryUpdatedEventHandler, StoryDeletedEventHandler
- TaskCreatedEventHandler, TaskUpdatedEventHandler, TaskDeletedEventHandler
- TaskAssignedEventHandler

Infrastructure Extensions:
- Extended IProjectNotificationService with Epic/Story/Task methods
- Extended IRealtimeNotificationService with Epic/Story/Task methods
- Extended RealtimeNotificationService with implementations
- Extended ProjectNotificationServiceAdapter for delegation

Domain Changes:
- Updated EpicCreatedEvent to include TenantId (consistency with other events)
- Added Epic/Story/Task CRUD methods to Project aggregate root
- All operations raise appropriate domain events

Broadcasting Strategy:
- Created events: Broadcast to both project-{projectId} and tenant-{tenantId} groups
- Updated events: Broadcast to project-{projectId} group only
- Deleted events: Broadcast to project-{projectId} group only
- Assigned events: Broadcast to project-{projectId} group with assignment details

Test Results:
- All 192 domain tests passing
- Domain and Application layers compile successfully
- Event handlers auto-registered by MediatR

Files Changed:
- 9 new domain event files
- 10 new event handler files
- 3 service interfaces extended
- 2 service implementations extended
- 1 aggregate updated with event raising logic
- 1 test file updated for new event signature

Status: Complete real-time collaboration for ProjectManagement module

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-04 20:56:08 +01:00

38 lines
1.4 KiB
C#

using MediatR;
using Microsoft.Extensions.Logging;
using ColaFlow.Modules.ProjectManagement.Domain.Events;
using ColaFlow.Modules.ProjectManagement.Application.Services;
namespace ColaFlow.Modules.ProjectManagement.Application.EventHandlers;
/// <summary>
/// Handler for TaskAssignedEvent - sends SignalR notification
/// </summary>
public class TaskAssignedEventHandler : INotificationHandler<TaskAssignedEvent>
{
private readonly IProjectNotificationService _notificationService;
private readonly ILogger<TaskAssignedEventHandler> _logger;
public TaskAssignedEventHandler(
IProjectNotificationService notificationService,
ILogger<TaskAssignedEventHandler> logger)
{
_notificationService = notificationService;
_logger = logger;
}
public async Task Handle(TaskAssignedEvent notification, CancellationToken cancellationToken)
{
_logger.LogInformation("Handling TaskAssignedEvent for task {TaskId}", notification.TaskId);
await _notificationService.NotifyTaskAssigned(
notification.TenantId.Value,
notification.ProjectId.Value,
notification.TaskId.Value,
notification.AssigneeId.Value);
_logger.LogInformation("SignalR notification sent for task {TaskId} assigned to {AssigneeId}",
notification.TaskId, notification.AssigneeId);
}
}