using System.Collections.Generic; using System.Data.Common; using System.Threading; using System.Threading.Tasks; using GB5Shared.DTO.Draft; using GB5Shared.DTO.Framework.Login; namespace GB5Shared.Draft { public interface IDraftRowBLL { /// /// Auto-saves the draft header (every 30s timer or significant action). /// Allocates a DraftId via AutoNumber on first call. /// Returns the DraftId for the FE to store and reuse. /// Task UpsertHeaderAsync( DraftSessionDTO dto, LoginDTO login, CancellationToken ct); /// /// Upserts one dirty row. Rejects RowState=Unchanged silently (log warning only). /// High-frequency endpoint — intentionally lightweight. /// Task UpsertRowAsync( DraftRowDTO dto, LoginDTO login, CancellationToken ct); /// Returns the draft header for the given session, or null if not found. Task GetDraftHeaderAsync(string sessionGuid, LoginDTO login, CancellationToken ct); /// Returns all dirty rows for crash recovery, ordered for tree reconstruction. Task GetDraftRowsAsync(string sessionGuid, LoginDTO login, CancellationToken ct); /// /// Typed dirty-row fetch for entity-BLL promotion at final Save (distinct from the /// JSON-returning GetDraftRowsAsync used by the FE-facing GetDraftRows endpoint). /// Entity BLLs partition the result via DraftRowBLL.DeserializeRows/GetServerIds. /// Task> GetDraftRowsForPromotionAsync(string sessionGuid, LoginDTO login, CancellationToken ct); /// Returns draft pool items for the sharing/resume screen. Task GetDraftPoolAsync(int menuId, LoginDTO login, CancellationToken ct); /// Discards the draft. ActionType=8=Discarded. Task DiscardDraftAsync(string sessionGuid, LoginDTO login, CancellationToken ct); /// /// Shares the draft to targetUserId. /// Application-layer ownership check precedes the SP call (defence in depth). /// Task ShareDraftAsync(DraftShareDTO dto, LoginDTO login, CancellationToken ct); /// /// Deletes TDRAFT_ROWS + TDRAFT for the session after a successful final save. /// MUST be called inside the entity's save transaction (tx). /// ActionType=7=Submitted. /// Task CleanupAfterSaveAsync(string sessionGuid, LoginDTO login, DbTransaction tx, CancellationToken ct); } }