using Microsoft.EntityFrameworkCore;
using SolutionErp.Domain.Budgets;
using SolutionErp.Domain.Contracts;
using SolutionErp.Domain.Contracts.Details;
using SolutionErp.Domain.Forms;
using SolutionErp.Domain.Identity;
using SolutionErp.Domain.Master;
using SolutionErp.Domain.Master.Catalogs;
using SolutionErp.Domain.Notifications;
using SolutionErp.Domain.PurchaseEvaluations;

namespace SolutionErp.Application.Common.Interfaces;

public interface IApplicationDbContext
{
    DbSet<Supplier> Suppliers { get; }
    DbSet<Project> Projects { get; }
    DbSet<Department> Departments { get; }
    // 4 master catalogs cho Details add form (autocomplete)
    DbSet<UnitOfMeasure> UnitsOfMeasure { get; }
    DbSet<MaterialItem> MaterialItems { get; }
    DbSet<ServiceItem> ServiceItems { get; }
    DbSet<WorkItem> WorkItems { get; }
    DbSet<MenuItem> MenuItems { get; }
    DbSet<Permission> Permissions { get; }
    DbSet<User> Users { get; }
    DbSet<Role> Roles { get; }
    DbSet<ContractTemplate> ContractTemplates { get; }
    DbSet<ContractClause> ContractClauses { get; }
    DbSet<Contract> Contracts { get; }
    DbSet<ContractApproval> ContractApprovals { get; }
    DbSet<ContractComment> ContractComments { get; }
    DbSet<ContractAttachment> ContractAttachments { get; }
    DbSet<ContractCodeSequence> ContractCodeSequences { get; }
    DbSet<ContractChangelog> ContractChangelogs { get; }
    DbSet<ContractDepartmentApproval> ContractDepartmentApprovals { get; }
    DbSet<Notification> Notifications { get; }
    DbSet<WorkflowTypeAssignment> WorkflowTypeAssignments { get; }
    DbSet<WorkflowDefinition> WorkflowDefinitions { get; }
    DbSet<WorkflowStep> WorkflowSteps { get; }
    DbSet<WorkflowStepApprover> WorkflowStepApprovers { get; }

    // Per-type Details DbSets (Option B — bảng riêng từng loại HĐ)
    DbSet<ThauPhuDetail> ThauPhuDetails { get; }
    DbSet<GiaoKhoanDetail> GiaoKhoanDetails { get; }
    DbSet<NhaCungCapDetail> NhaCungCapDetails { get; }
    DbSet<DichVuDetail> DichVuDetails { get; }
    DbSet<MuaBanDetail> MuaBanDetails { get; }
    DbSet<NguyenTacNccDetail> NguyenTacNccDetails { get; }
    DbSet<NguyenTacDvDetail> NguyenTacDvDetails { get; }

    // Module Duyệt NCC (tiền-HĐ) — 7 core + 3 workflow config
    DbSet<PurchaseEvaluation> PurchaseEvaluations { get; }
    DbSet<PurchaseEvaluationSupplier> PurchaseEvaluationSuppliers { get; }
    DbSet<PurchaseEvaluationDetail> PurchaseEvaluationDetails { get; }
    DbSet<PurchaseEvaluationQuote> PurchaseEvaluationQuotes { get; }
    DbSet<PurchaseEvaluationApproval> PurchaseEvaluationApprovals { get; }
    DbSet<PurchaseEvaluationChangelog> PurchaseEvaluationChangelogs { get; }
    DbSet<PurchaseEvaluationAttachment> PurchaseEvaluationAttachments { get; }
    DbSet<PurchaseEvaluationWorkflowDefinition> PurchaseEvaluationWorkflowDefinitions { get; }
    DbSet<PurchaseEvaluationWorkflowStep> PurchaseEvaluationWorkflowSteps { get; }
    DbSet<PurchaseEvaluationWorkflowStepApprover> PurchaseEvaluationWorkflowStepApprovers { get; }
    DbSet<PurchaseEvaluationCodeSequence> PurchaseEvaluationCodeSequences { get; }
    DbSet<PurchaseEvaluationDepartmentOpinion> PurchaseEvaluationDepartmentOpinions { get; }
    DbSet<PurchaseEvaluationDepartmentApproval> PurchaseEvaluationDepartmentApprovals { get; }

    // Module Ngân sách (Phase 7)
    DbSet<Budget> Budgets { get; }
    DbSet<BudgetDetail> BudgetDetails { get; }
    DbSet<BudgetApproval> BudgetApprovals { get; }
    DbSet<BudgetChangelog> BudgetChangelogs { get; }
    DbSet<BudgetDepartmentApproval> BudgetDepartmentApprovals { get; }

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