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

namespace Books.Api.EventFlow.ReadModels;

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