using Books.Api.Domain.Attachments;
using Books.Api.Domain.Attachments.Events;
using EventFlow.Aggregates;
using EventFlow.ReadStores;

namespace Books.Api.EventFlow.ReadModels;

/// <summary>
/// Locator for attachment read models.
/// Uses aggregate ID as the read model ID.
/// </summary>
public class AttachmentReadModelLocator : IReadModelLocator
{
    public IEnumerable<string> GetReadModelIds(IDomainEvent domainEvent)
    {
        if (domainEvent.GetAggregateEvent() is IAggregateEvent<AttachmentAggregate, AttachmentId>)
        {
            yield return domainEvent.GetIdentity().Value;
        }
    }
}
