using DocumentService.Application.Common.DTOs;
namespace DocumentService.Client.Models.Results;
///
/// Combined result of a PDF validation followed by a Swiss QR Code extraction.
/// Both operations are always executed; is null when
/// the document fails validation.
///
///
/// Extracted Swiss QR Code data, or null if the PDF was invalid or did not
/// contain a recognisable Swiss QR Code.
///
///
/// PDF validation result. Always populated regardless of whether extraction succeeded.
/// Use
/// to determine whether the extraction was attempted.
///
public record SwissQrCodeResult(
SwissQrCodeExtractionResult? QrCode,
PdfValidationResult Validation)
{
///
/// Optional convenience method for code readability. Follows the standard
/// TryXxx pattern (e.g. ,
/// ).
/// Use it when you prefer an if/else branch over a null-check on ;
/// it is not required – both approaches are equivalent.
///
///
/// When this method returns true, contains the extracted QR Code data.
/// When this method returns false, this value is null and must not be used.
///
///
/// true if the PDF was valid and a Swiss QR Code was successfully extracted;
/// false otherwise.
///
public bool TryExtract(out SwissQrCodeExtractionResult qrCode)
{
qrCode = QrCode ?? null!;
return Validation.IsValid && QrCode is not null;
}
}