using Books.Api.Domain.Invoices;
using EventFlow.Aggregates;
using EventFlow.ReadStores;

namespace Books.Api.EventFlow.ReadModels;

/// <summary>
/// Locator for Invoice read models.
/// Maps domain events to the read model identifier.
/// </summary>
public class InvoiceReadModelLocator : IReadModelLocator
{
    public IEnumerable<string> GetReadModelIds(IDomainEvent domainEvent)
    {
        if (domainEvent.GetAggregateEvent() is IAggregateEvent<InvoiceAggregate, InvoiceId>)
        {
            yield return domainEvent.GetIdentity().Value;
        }
    }
}
