using e_suite.Database.Core.Helpers;
using e_suite.Database.Core.Tables.Activity;
using e_suite.Database.Core.Tables.Contacts;
using e_suite.Database.Core.Tables.CustomFields;
using e_suite.Database.Core.Tables.Diagnostics;
using e_suite.Database.Core.Tables.Domain;
using e_suite.Database.Core.Tables.Forms;
using e_suite.Database.Core.Tables.Glossaries;
using e_suite.Database.Core.Tables.Mail;
using e_suite.Database.Core.Tables.Miscellaneous;
using e_suite.Database.Core.Tables.Printer;
using e_suite.Database.Core.Tables.Sentinel;
using e_suite.Database.Core.Tables.Sequences;
using e_suite.Database.Core.Tables.UserManager;
using e_suite.Database.Core.Tables.Workflow;
using eSuite.Core.Clock;
using Microsoft.EntityFrameworkCore;

namespace e_suite.Database.Core;

public class EsuiteDatabaseDbContext : SunDatabaseEntityContext, IEsuiteDatabaseDbContext
{
    public EsuiteDatabaseDbContext(DbContextOptions options, IClock clock) : base(options, clock)
    {
    }

    public IQueryable Set(Type entityType)
    {
        return (IQueryable)typeof(DbContext)
            .GetMethod(nameof(DbContext.Set), Type.EmptyTypes)!
            .MakeGenericMethod(entityType)
            .Invoke(this, null)!;
    }

    public DbSet<User> Users { get; set; } = null!;
    public DbSet<SsoProvider> SsoProviders { get; set; } = null!;
    public DbSet<SingleUseGuid> SingleUseGuids { get; set; }
    public DbSet<EmailUserAction> EmailUserActions { get; set; } = null!;
    public DbSet<FailedAccessAttempt> FailedAccessAttempts { get; set; } = null!;
    public DbSet<ExceptionLog> ExceptionLogs { get; set; } = null!;
    public DbSet<PerformanceReport> PerformanceReports { get; set; } = null!;
    public DbSet<PerformanceThreshold> PerformanceThresholds { get; set; } = null!;
    public DbSet<Sequence> Sequences { get; set; } = null!;
    public DbSet<CustomField> CustomFields { get; set; } = null!;
    public DbSet<CustomFieldSequence> CustomFieldSequences { get; set; } = null!;
    public DbSet<CustomFieldFormTemplate> CustomFieldFormTemplate { get; set; } = null!;
    public DbSet<CustomFieldGlossary> CustomFieldGlossaries { get; set; } = null!;
    public DbSet<CustomFieldNumber> CustomFieldNumber { get; set; } = null!;
    public DbSet<CustomFieldText> CustomFieldText { get; set; } = null!;
    public DbSet<FormTemplate> FormTemplates { get; set; } = null!;
    public DbSet<FormTemplateVersion> FormTemplateVersions { get; set; } = null!;
    public DbSet<FormFieldInstance> FormFieldInstances { get; set; } = null!;
    public DbSet<FormInstance> FormInstances { get; set; } = null!;
    public DbSet<Glossary> Glossaries { get; set; } = null!;
    public DbSet<GlossaryCustomField> GlossaryCustomFields { get; set; } = null!;
    public DbSet<GlossaryCustomFieldValue> GlossaryCustomFieldValues { get; set; } = null!;
    public DbSet<Organisation> Organisations { get; set; } = null!;
    public DbSet<Site> Sites { get; set; } = null!;
    public DbSet<Specification> Specifications { get; set; } = null!;
    public DbSet<Contact> Contacts {get; set; } = null!;
    public DbSet<OrganisationContact> OrganisationContacts { get; set; } = null!;
    public DbSet<SiteContact> SiteContacts {get; set; } = null!;
    public DbSet<Domain> Domains { get; set; } = null!;
    public DbSet<Role> Roles { get; set; }
    public DbSet<UserRole> UserRoles { get; set; }
    public DbSet<RoleAccess> RoleAccess { get; set; }
#pragma warning disable IDE1006 // Naming Styles
    protected DbSet<UserAccess> userAccess { get; set; } = null!;
#pragma warning restore IDE1006 // Naming Styles
    public IQueryable<UserAccess> UserAccess => userAccess.AsNoTracking();
    public DbSet<MailTemplate> MailTemplates { get; set; } = null!;
    public DbSet<ExternalSystem> ExternalSystems { get; set; }
    public DbSet<ExternalKey> ExternalKeys { get; set; }
    public DbSet<Workflow> Workflows { get; set; }
    public DbSet<WorkflowVersion> WorkflowVersions { get; set; }
    public DbSet<Activity> Activities { get; set; }
    public DbSet<ActivityTask> ActivityTasks { get; set; }
    public DbSet<ActivityAssignment> ActivityAssignments { get; set; }
}