using System.Collections.Generic; using System.Data.Common; using System.Threading; using System.Threading.Tasks; using FrameworkDAL.CustomCode.EntityViewer.DTOs; using GB5Shared.DTO.Framework.Login; namespace FrameworkDAL.CustomCode.EntityViewer { // ============================================================ // IEntityLayoutDAL — Data access for the Entity Viewer layout registry. // // Activation uses TWO queries (ArchiveActiveVersion + ActivateVersion) // that MUST be called inside the same transaction to prevent // dual-active-version on crash. // ============================================================ public interface IEntityLayoutDAL { Task SaveLayout(EntityLayoutDTO dto, LoginDTO loginDTO, CancellationToken ct = default); Task UpdateLayout(EntityLayoutDTO dto, LoginDTO loginDTO, CancellationToken ct = default); Task DeleteLayout(int entityLayoutId, int modifiedById, LoginDTO loginDTO, CancellationToken ct = default); Task GetLayoutHeaderById(int entityLayoutId, LoginDTO loginDTO, CancellationToken ct = default); /// /// Resolves the Active layout for (EntityCode, TenantId): a TenantId-scoped /// override wins if it has an Active version, otherwise falls back to the /// TenantId IS NULL global default. /// Task GetActiveLayout(string entityCode, int tenantId, LoginDTO loginDTO, CancellationToken ct = default); Task SaveLayoutVersion(EntityLayoutVersionDTO dto, LoginDTO loginDTO, CancellationToken ct = default); /// Updates a version's SnapshotJson/VersionLabel in place. Only takes effect /// while the version is still Draft (VERSIONSTATUS = 0) — returns 0 rows affected /// otherwise, which the BLL turns into an explicit error. Task UpdateLayoutVersion(EntityLayoutVersionDTO dto, LoginDTO loginDTO, CancellationToken ct = default); /// Soft-deletes a version. Only takes effect while still Draft — an /// Active/Archived version can never be discarded. Task DeleteLayoutVersion(int entityLayoutVersionId, int modifiedById, LoginDTO loginDTO, CancellationToken ct = default); Task> GetLayoutVersionList(int entityLayoutId, LoginDTO loginDTO, CancellationToken ct = default); /// All layout headers with IsComponent = , joined /// to their current Active version summary and (for real entity types) MENTITY's /// display name — the Layout Designer's list screen. Task> GetLayoutList(bool isComponent, LoginDTO loginDTO, CancellationToken ct = default); Task ArchiveActiveVersion(int entityLayoutId, int modifiedById, LoginDTO loginDTO, DbTransaction tx, CancellationToken ct = default); Task ActivateVersion(int entityLayoutVersionId, int modifiedById, LoginDTO loginDTO, DbTransaction tx, CancellationToken ct = default); } }