using ScadaLink.Commons.Entities.Instances;
using ScadaLink.Commons.Entities.Sites;

namespace ScadaLink.Commons.Interfaces.Repositories;

/// <summary>
/// Repository interface for site and data connection management.
/// </summary>
public interface ISiteRepository
{
    // Sites
    Task<Site?> GetSiteByIdAsync(int id, CancellationToken cancellationToken = default);
    Task<Site?> GetSiteByIdentifierAsync(string siteIdentifier, CancellationToken cancellationToken = default);
    Task<IReadOnlyList<Site>> GetAllSitesAsync(CancellationToken cancellationToken = default);
    Task AddSiteAsync(Site site, CancellationToken cancellationToken = default);
    Task UpdateSiteAsync(Site site, CancellationToken cancellationToken = default);
    Task DeleteSiteAsync(int id, CancellationToken cancellationToken = default);

    // Data Connections
    Task<DataConnection?> GetDataConnectionByIdAsync(int id, CancellationToken cancellationToken = default);
    Task<IReadOnlyList<DataConnection>> GetAllDataConnectionsAsync(CancellationToken cancellationToken = default);
    Task<IReadOnlyList<DataConnection>> GetDataConnectionsBySiteIdAsync(int siteId, CancellationToken cancellationToken = default);
    Task AddDataConnectionAsync(DataConnection connection, CancellationToken cancellationToken = default);
    Task UpdateDataConnectionAsync(DataConnection connection, CancellationToken cancellationToken = default);
    Task DeleteDataConnectionAsync(int id, CancellationToken cancellationToken = default);

    // Instances (for deletion constraint checks)
    Task<IReadOnlyList<Instance>> GetInstancesBySiteIdAsync(int siteId, CancellationToken cancellationToken = default);

    Task<int> SaveChangesAsync(CancellationToken cancellationToken = default);
}
