32 lines
984 B
C#
32 lines
984 B
C#
using IM_API.Domain.Events;
|
|
using MassTransit;
|
|
|
|
namespace IM_API.Application.EventHandlers.GroupRequestHandler
|
|
{
|
|
public class NextEventHandler : IConsumer<GroupRequestEvent>
|
|
{
|
|
private readonly IPublishEndpoint _endpoint;
|
|
public NextEventHandler(IPublishEndpoint endpoint)
|
|
{
|
|
_endpoint = endpoint;
|
|
}
|
|
|
|
public async Task Consume(ConsumeContext<GroupRequestEvent> context)
|
|
{
|
|
var @event = context.Message;
|
|
if(@event.Action == Models.GroupRequestState.Passed)
|
|
{
|
|
await _endpoint.Publish(new GroupJoinEvent
|
|
{
|
|
AggregateId = @event.AggregateId,
|
|
OccurredAt = @event.OccurredAt,
|
|
EventId = Guid.NewGuid(),
|
|
GroupId = @event.GroupId,
|
|
OperatorId = @event.OperatorId,
|
|
UserId = @event.UserId
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|