namespace Fengling.Platform.Infrastructure;

using Fengling.Platform.Domain.AggregatesModel.TenantAggregate;

public interface ITenantStore
{
    Task<Tenant?> FindByIdAsync(long? tenantId, CancellationToken cancellationToken = default);
    Task<Tenant?> FindByTenantCodeAsync(string tenantCode, CancellationToken cancellationToken = default);
    Task<IList<Tenant>> GetAllAsync(CancellationToken cancellationToken = default);
    Task<IList<Tenant>> GetPagedAsync(int page, int pageSize, string? name = null, string? tenantCode = null, TenantStatus? status = null, CancellationToken cancellationToken = default);
    Task<int> GetCountAsync(string? name = null, string? tenantCode = null, TenantStatus? status = null, CancellationToken cancellationToken = default);
    Task<int> GetUserCountAsync(long tenantId, CancellationToken cancellationToken = default);
    Task<Microsoft.AspNetCore.Identity.IdentityResult> CreateAsync(Tenant tenant, CancellationToken cancellationToken = default);
    Task<Microsoft.AspNetCore.Identity.IdentityResult> UpdateAsync(Tenant tenant, CancellationToken cancellationToken = default);
    Task<Microsoft.AspNetCore.Identity.IdentityResult> DeleteAsync(Tenant tenant, CancellationToken cancellationToken = default);

    Task<string> GetTenantCodeAsync(Tenant tenant, CancellationToken cancellationToken = default);
    Task<string> GetNameAsync(Tenant tenant, CancellationToken cancellationToken = default);
    Task<string> GetContactNameAsync(Tenant tenant, CancellationToken cancellationToken = default);
    Task<string> GetContactEmailAsync(Tenant tenant, CancellationToken cancellationToken = default);
    Task<string?> GetContactPhoneAsync(Tenant tenant, CancellationToken cancellationToken = default);
    Task<int?> GetMaxUsersAsync(Tenant tenant, CancellationToken cancellationToken = default);
    Task<string?> GetDescriptionAsync(Tenant tenant, CancellationToken cancellationToken = default);
    Task<TenantStatus> GetStatusAsync(Tenant tenant, CancellationToken cancellationToken = default);
    Task<DateTime?> GetExpiresAtAsync(Tenant tenant, CancellationToken cancellationToken = default);
    Task<DateTime> GetCreatedAtAsync(Tenant tenant, CancellationToken cancellationToken = default);
    Task<DateTime?> GetUpdatedAtAsync(Tenant tenant, CancellationToken cancellationToken = default);

    Task SetTenantCodeAsync(Tenant tenant, string code, CancellationToken cancellationToken = default);
    Task SetNameAsync(Tenant tenant, string name, CancellationToken cancellationToken = default);
    Task SetContactNameAsync(Tenant tenant, string name, CancellationToken cancellationToken = default);
    Task SetContactEmailAsync(Tenant tenant, string email, CancellationToken cancellationToken = default);
    Task SetContactPhoneAsync(Tenant tenant, string? phone, CancellationToken cancellationToken = default);
    Task SetMaxUsersAsync(Tenant tenant, int? maxUsers, CancellationToken cancellationToken = default);
    Task SetDescriptionAsync(Tenant tenant, string? description, CancellationToken cancellationToken = default);
    Task SetStatusAsync(Tenant tenant, TenantStatus status, CancellationToken cancellationToken = default);
    Task SetExpiresAtAsync(Tenant tenant, DateTime? expiresAt, CancellationToken cancellationToken = default);
}
