using Fengling.Console.Models.Entities;
using Microsoft.AspNetCore.Identity;

namespace Fengling.Console.Stores;

public interface ITenantStore<TTenant> : IDisposable where TTenant : class
{
    Task<TTenant?> FindByIdAsync(int tenantId, CancellationToken cancellationToken = default);
    Task<TTenant?> FindByTenantCodeAsync(string tenantCode, CancellationToken cancellationToken = default);
    Task<IList<TTenant>> GetAllAsync(CancellationToken cancellationToken = default);
    Task<IList<TTenant>> 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<IdentityResult> CreateAsync(TTenant tenant, CancellationToken cancellationToken = default);
    Task<IdentityResult> UpdateAsync(TTenant tenant, CancellationToken cancellationToken = default);
    Task<IdentityResult> DeleteAsync(TTenant tenant, CancellationToken cancellationToken = default);
    Task<int> GetUserCountAsync(int tenantId, CancellationToken cancellationToken = default);
    
    Task<string> GetTenantCodeAsync(TTenant tenant, CancellationToken cancellationToken = default);
    Task<string> GetNameAsync(TTenant tenant, CancellationToken cancellationToken = default);
    Task<string> GetContactNameAsync(TTenant tenant, CancellationToken cancellationToken = default);
    Task<string> GetContactEmailAsync(TTenant tenant, CancellationToken cancellationToken = default);
    Task<string?> GetContactPhoneAsync(TTenant tenant, CancellationToken cancellationToken = default);
    Task<int?> GetMaxUsersAsync(TTenant tenant, CancellationToken cancellationToken = default);
    Task<string?> GetDescriptionAsync(TTenant tenant, CancellationToken cancellationToken = default);
    Task<TenantStatus> GetStatusAsync(TTenant tenant, CancellationToken cancellationToken = default);
    Task<DateTime?> GetExpiresAtAsync(TTenant tenant, CancellationToken cancellationToken = default);
    Task<DateTime> GetCreatedAtAsync(TTenant tenant, CancellationToken cancellationToken = default);
    Task<DateTime?> GetUpdatedAtAsync(TTenant tenant, CancellationToken cancellationToken = default);
    Task<bool> GetIsDeletedAsync(TTenant tenant, CancellationToken cancellationToken = default);
    
    Task SetTenantCodeAsync(TTenant tenant, string code, CancellationToken cancellationToken = default);
    Task SetNameAsync(TTenant tenant, string name, CancellationToken cancellationToken = default);
    Task SetContactNameAsync(TTenant tenant, string name, CancellationToken cancellationToken = default);
    Task SetContactEmailAsync(TTenant tenant, string email, CancellationToken cancellationToken = default);
    Task SetContactPhoneAsync(TTenant tenant, string? phone, CancellationToken cancellationToken = default);
    Task SetMaxUsersAsync(TTenant tenant, int? maxUsers, CancellationToken cancellationToken = default);
    Task SetDescriptionAsync(TTenant tenant, string? description, CancellationToken cancellationToken = default);
    Task SetStatusAsync(TTenant tenant, TenantStatus status, CancellationToken cancellationToken = default);
    Task SetExpiresAtAsync(TTenant tenant, DateTime? expiresAt, CancellationToken cancellationToken = default);
    Task SetIsDeletedAsync(TTenant tenant, bool isDeleted, CancellationToken cancellationToken = default);
}
