namespace PromotionService.Domain.Exceptions;

/// <summary>
/// EN: Base exception for Promotion domain errors.
/// VI: Exception cơ sở cho lỗi domain Promotion.
/// </summary>
public class PromotionDomainException : Exception
{
    public PromotionDomainException() { }
    public PromotionDomainException(string message) : base(message) { }
    public PromotionDomainException(string message, Exception innerException) : base(message, innerException) { }
}

/// <summary>
/// EN: Exception when trying to operate on a non-active campaign.
/// VI: Exception khi cố thao tác trên chiến dịch không hoạt động.
/// </summary>
public class CampaignNotActiveException : PromotionDomainException
{
    public Guid CampaignId { get; }

    public CampaignNotActiveException(Guid campaignId)
        : base($"Campaign {campaignId} is not active")
    {
        CampaignId = campaignId;
    }
}

/// <summary>
/// EN: Exception when a voucher has already been claimed.
/// VI: Exception khi voucher đã được nhận.
/// </summary>
public class VoucherAlreadyClaimedException : PromotionDomainException
{
    public Guid VoucherId { get; }
    public string VoucherCode { get; }

    public VoucherAlreadyClaimedException(Guid voucherId, string code)
        : base($"Voucher {code} has already been claimed")
    {
        VoucherId = voucherId;
        VoucherCode = code;
    }
}

/// <summary>
/// EN: Exception when a voucher has expired.
/// VI: Exception khi voucher đã hết hạn.
/// </summary>
public class VoucherExpiredException : PromotionDomainException
{
    public Guid VoucherId { get; }
    public string VoucherCode { get; }

    public VoucherExpiredException(Guid voucherId, string code)
        : base($"Voucher {code} has expired")
    {
        VoucherId = voucherId;
        VoucherCode = code;
    }
}

/// <summary>
/// EN: Exception when voucher has insufficient value for redemption.
/// VI: Exception khi voucher không đủ giá trị để sử dụng.
/// </summary>
public class InsufficientVoucherValueException : PromotionDomainException
{
    public Guid VoucherId { get; }
    public decimal RemainingValue { get; }
    public decimal RequestedAmount { get; }

    public InsufficientVoucherValueException(Guid voucherId, decimal remaining, decimal requested)
        : base($"Voucher has insufficient value. Remaining: {remaining}, Requested: {requested}")
    {
        VoucherId = voucherId;
        RemainingValue = remaining;
        RequestedAmount = requested;
    }
}
