using NexusReader.Domain.Entities;

namespace NexusReader.Application.Abstractions.Persistence;

/// <summary>
/// Abstraction for Ebook and Author persistence operations.
/// Defined in the Application layer to avoid a direct dependency on EF Core.
/// </summary>
public interface IEbookRepository
{
    /// <summary>
    /// Finds an author by name using a case-insensitive comparison.
    /// </summary>
    Task<Author?> FindAuthorByNameAsync(string name, CancellationToken cancellationToken = default);

    /// <summary>
    /// Adds a new author to the repository (staged, not yet persisted).
    /// </summary>
    void AddAuthor(Author author);

    /// <summary>
    /// Adds a new ebook to the repository (staged, not yet persisted).
    /// </summary>
    void AddEbook(Ebook ebook);

    /// <summary>
    /// Finds an ebook by its unique identifier.
    /// </summary>
    Task<Ebook?> FindByIdAsync(Guid id, CancellationToken cancellationToken = default);

    /// <summary>
    /// Persists all staged changes to the underlying store.
    /// </summary>
    Task<int> SaveChangesAsync(CancellationToken cancellationToken = default);
}
