-- =============================================
-- Insert Configuration for Strategy Selection
-- =============================================

-- Check if config exists, insert if not
IF NOT EXISTS (SELECT 1 FROM CMS.SystemConfigurations WHERE [Key] = 'Commission.CalculationStrategy')
BEGIN
    INSERT INTO CMS.SystemConfigurations ([Key], [Value], [Description], IsActive, Created, CreatedBy, LastModified, LastModifiedBy)
    VALUES (
        'Commission.CalculationStrategy', 
        'ORM', 
        N'روش محاسبه کمیسیون: ORM (Entity Framework) یا SP (Stored Procedure)',
        1,
        GETDATE(),
        'System',
        GETDATE(),
        'System'
    );
    PRINT 'Configuration Commission.CalculationStrategy created with default value: ORM'
END
ELSE
BEGIN
    PRINT 'Configuration Commission.CalculationStrategy already exists'
END

-- Show current value
SELECT [Key], [Value], [Description] 
FROM CMS.SystemConfigurations 
WHERE [Key] LIKE 'Commission.%'
ORDER BY [Key];

/*
    تغییر روش محاسبه:
    
    -- برای استفاده از ORM (Entity Framework):
    UPDATE CMS.SystemConfigurations SET Value = 'ORM' WHERE [Key] = 'Commission.CalculationStrategy'
    
    -- برای استفاده از Stored Procedure:
    UPDATE CMS.SystemConfigurations SET Value = 'SP' WHERE [Key] = 'Commission.CalculationStrategy'
*/
