namespace AdsTrackingService.Domain.SeedWork;

/// <summary>
/// EN: Generic repository interface for aggregate roots.
/// VI: Interface repository generic cho aggregate roots.
/// </summary>
/// <typeparam name="T">EN: The aggregate root type / VI: Kiểu aggregate root</typeparam>
public interface IRepository<T> where T : IAggregateRoot
{
    /// <summary>
    /// EN: The unit of work for this repository.
    /// VI: Unit of work cho repository này.
    /// </summary>
    IUnitOfWork UnitOfWork { get; }

    /// <summary>
    /// EN: Get entity by ID.
    /// VI: Lấy entity theo ID.
    /// </summary>
    Task<T?> GetByIdAsync(Guid id, CancellationToken ct = default);

    /// <summary>
    /// EN: Add a new entity.
    /// VI: Thêm entity mới.
    /// </summary>
    Task<T> AddAsync(T entity, CancellationToken ct = default);

    /// <summary>
    /// EN: Update an existing entity.
    /// VI: Cập nhật entity đã tồn tại.
    /// </summary>
    T Update(T entity);

    /// <summary>
    /// EN: Delete an entity.
    /// VI: Xóa entity.
    /// </summary>
    void Delete(T entity);
}
