feat: implement SignalR notifications for project status changes

This commit is contained in:
2025-12-14 12:13:23 +03:30
parent 14fda440c1
commit da46d45601
8 changed files with 80 additions and 8 deletions

View File

@@ -0,0 +1,23 @@
using GozareshgirProgramManager.Application._Common.Models;
using GozareshgirProgramManager.Application.Interfaces;
using GozareshgirProgramManager.Domain.ProjectAgg.Events;
using MediatR;
namespace GozareshgirProgramManager.Application.DomainEventHandlers.ProjectSection;
public class TaskSectionStatusChangedHandler:INotificationHandler<DomainEventNotification<TaskSectionStatusChangedEvent>>
{
private readonly IBoardNotificationPublisher _boardNotificationPublisher;
public TaskSectionStatusChangedHandler(IBoardNotificationPublisher boardNotificationPublisher)
{
_boardNotificationPublisher = boardNotificationPublisher;
}
public Task Handle(DomainEventNotification<TaskSectionStatusChangedEvent> notification, CancellationToken cancellationToken)
{
var domainEvent = notification.DomainEvent;
_boardNotificationPublisher.SendProjectStatusChanged(domainEvent.UserId,domainEvent.OldStatus,domainEvent.NewStatus,domainEvent.SectionId);
return Task.CompletedTask;
}
}

View File

@@ -0,0 +1,9 @@
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
namespace GozareshgirProgramManager.Application.Interfaces;
public interface IBoardNotificationPublisher
{
Task SendProjectStatusChanged(long userId, TaskSectionStatus oldStatus,
TaskSectionStatus newStatus, Guid sectionId);
}

View File

@@ -1,6 +0,0 @@
namespace GozareshgirProgramManager.Application.Interfaces;
public interface IBoardNotificationService
{
Task SendProjectAssignedAsync();
}

View File

@@ -159,7 +159,7 @@ public class TaskSection : EntityBase<Guid>
{
var oldStatus = Status;
Status = status;
AddDomainEvent(new TaskSectionStatusChangedEvent(Id, oldStatus, status));
AddDomainEvent(new TaskSectionStatusChangedEvent(Id, oldStatus, status,CurrentAssignedUserId));
}
public TimeSpan GetTotalTimeSpent()

View File

@@ -104,7 +104,8 @@ public record TaskSectionRemovedEvent(Guid TaskId, Guid SectionId) : IDomainEven
}
// TaskSection Events
public record TaskSectionStatusChangedEvent(Guid SectionId, TaskSectionStatus OldStatus, TaskSectionStatus NewStatus) : IDomainEvent
public record TaskSectionStatusChangedEvent(Guid SectionId, TaskSectionStatus OldStatus,
TaskSectionStatus NewStatus,long UserId) : IDomainEvent
{
public DateTime OccurredOn { get; init; } = DateTime.UtcNow;
}