using System.Data.Common;
using System.Threading.Tasks;
using GB5Shared.DTO.Framework.Login;
using GoodBooks.PAY.PAYDAL.DTO.Loyalty;
namespace GoodBooks.PAY.PAYDAL.CustomCode.Loyalty
{
///
/// Data-access contract for MLOYALTYPROGRAM.
/// Methods that write data accept an optional DbTransaction so they can participate
/// in multi-step BLL transactions (header + tiers + earn configs in one commit).
///
public interface ILoyaltyProgramDAL
{
///
/// Fetches a single loyalty program with embedded tier and earn-config child arrays.
/// Returns serialised JSON string.
///
Task GetLoyaltyProgram(int programId, LoginDTO login);
///
/// Returns a paged JSON list of active loyalty programs for the tenant.
///
Task GetLoyaltyProgramList(int pageOffset, int pageSize, LoginDTO login);
///
/// Inserts the program header row. Returns rows affected.
/// Caller is responsible for inserting child tiers and earn configs in the same transaction.
///
Task InsertLoyaltyProgram(LoyaltyProgramDTO dto, LoginDTO login, DbTransaction? tx);
///
/// Updates the program header row. Returns rows affected.
/// Caller must delete and re-insert tiers in the same transaction.
///
Task UpdateLoyaltyProgram(LoyaltyProgramDTO dto, LoginDTO login, DbTransaction? tx);
///
/// Deletes all tier rows for the given program (used before re-inserting updated tiers).
/// Must run in the same transaction as the subsequent tier inserts.
/// Returns rows affected.
///
Task DeleteLoyaltyTiersByProgram(int programId, LoginDTO login, DbTransaction? tx);
}
}