Rating Event Integration Mapper (Services/EventMapper.cs)

BookWorm · src/Services/Rating/BookWorm.Rating/Infrastructure/Services/EventMapper.cs · csharp · MIT
integration, infra, automation, lang:csharp

Maps internal domain events to external integration events for cross-service communication in a microservices architecture.

// Source: https://github.com/foxminchan/BookWorm | License: MIT | Copyright Nhan Nguyen (nguyenxuannhan407@gmail.com)
// Provided via justclaw.it.com; keep this notice with the code.
using BookWorm.Contracts;
using BookWorm.Rating.Domain.Events;

namespace BookWorm.Rating.Infrastructure.Services;

internal sealed class EventMapper : IEventMapper
{
    public IntegrationEvent MapToIntegrationEvent(DomainEvent @event)
    {
        return @event switch
        {
            FeedbackCreatedEvent feedbackCreatedEvent => new FeedbackCreatedIntegrationEvent(
                feedbackCreatedEvent.BookId,
                feedbackCreatedEvent.Rating,
                feedbackCreatedEvent.FeedbackId
            ),
            FeedbackDeletedEvent feedbackDeletedEvent => new FeedbackDeletedIntegratio

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key