using e_suite.Database.Audit;
using e_suite.Database.Core;
using e_suite.Database.Core.Helpers;
using e_suite.Database.Core.Tables.Forms;
using eSuite.Core.Miscellaneous;

namespace e_suite.API.Common.repository;

public interface IFormRepository : IRepository
{
    //FormTemplate
    Task<FormTemplate?> GetTemplateAsync(IGeneralIdRef id, CancellationToken cancellationToken);
    Task<FormTemplate?> GetTemplateWithOutLoadedRefereranceAsync(IGeneralIdRef id, CancellationToken cancellationToken);
    Task CreateTemplateAsync(AuditUserDetails auditUserDetails, FormTemplate template, CancellationToken cancellationToken);
    IQueryable<FormTemplate> GetTemplates();
    Task DeleteAllVersionsAsync(AuditUserDetails auditUserDetails, IEnumerable<FormTemplateVersion> formTemplateVersions, CancellationToken cancellationToken);
    Task EditFormTemplateAsync(AuditUserDetails auditUserDetails,FormTemplate formTemplate, CancellationToken cancellationToken);
    Task CreateNewFormVersionAsync(AuditUserDetails auditUserDetails, FormTemplateVersion formTemplateVersion, CancellationToken cancellationToken);
    IQueryable<FormTemplateVersion> GetAllFormVersions(long templateId);
    Task<FormTemplateVersion?> GetFormTemplateVersionAsync(IGeneralIdRef id, CancellationToken cancellationToken);
    Task<FormTemplate?> GetFormTemplateWithSpecificVersionAsync(IGeneralIdRef id, long formTemplateVersionId, CancellationToken cancellationToken);

    //FormInstances
    Task AddFormInstance(AuditUserDetails auditUserDetails, FormInstance newFormInstance, CancellationToken cancellationToken);
    Task AddFormInstances(AuditUserDetails auditUserDetails, IEnumerable<FormInstance> newFormInstance, CancellationToken cancellationToken);
    Task AddFormInstanceValues(AuditUserDetails auditUserDetails, List<FormFieldInstance> customFieldValues, CancellationToken cancellationToken);
    Task<FormInstance?> GetFormInstance(GeneralIdRef createFormInstanceId, bool tracking, CancellationToken cancellationToken);
    Task<List<FormInstance>> GetFormInstances(IEnumerable<GeneralIdRef> generalIdRefs, bool tracking, CancellationToken cancellationToken);
    Task SaveCustomFieldValues(AuditUserDetails auditUserDetails, Delta<FormFieldInstance> delta, CancellationToken cancellationToken);
    Task<IEnumerable<FormInstance>> GetFormsContainingFieldValue(IGeneralIdRef customFieldGeneralIdRef, string value, CancellationToken cancellationToken);
}
