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 MCUSTLOYALTYENROLLMENT.
///
public interface ICustomerLoyaltyEnrollmentDAL
{
///
/// Fetches a single enrollment by ID with program and tier names.
/// Returns serialised JSON string.
///
Task GetEnrollment(int enrollmentId, LoginDTO login);
///
/// Fetches a single enrollment for a customer+program combination.
/// Returns null when the customer is not enrolled.
///
Task GetEnrollmentByCustomerProgram(int customerId, int programId, LoginDTO login);
///
/// Returns the count of existing enrollments for a customer+program combination.
/// Used as an idempotency guard — BLL rejects enroll when count > 0.
///
Task CountEnrollment(int customerId, int programId, LoginDTO login);
///
/// Inserts a new enrollment row. Returns rows affected.
///
Task InsertEnrollment(CustomerLoyaltyEnrollmentDTO dto, LoginDTO login, DbTransaction? tx);
///
/// Updates the running point totals on an enrollment.
/// Called after every ledger transaction. Returns rows affected.
///
Task UpdateEnrollmentPoints(int enrollmentId, decimal currentPoints, decimal lifetimePoints, LoginDTO login, DbTransaction? tx);
///
/// Updates the tier assignment after a tier-upgrade evaluation.
/// Returns rows affected.
///
Task UpdateEnrollmentTier(int enrollmentId, int loyaltyTierId, LoginDTO login, DbTransaction? tx);
}
}