This commit is contained in:
Paul Schneider 2026-04-19 20:36:03 +01:00
commit 5620213cf5
5 changed files with 33 additions and 47 deletions

View file

@ -2,9 +2,9 @@ namespace Yavsc.Models.Billing
{
public static class BillingCodes
{
public const string Rdv = "Rdv";
public const string MBrush = "MBrush";
public const string Rdv = nameof(Rdv);
public const string MBrush = nameof(MBrush);
public const string Brush = "Brush";
public const string Brush = nameof(Brush);
}
}

View file

@ -46,26 +46,15 @@ namespace Yavsc.Helpers
lock (_billingLock)
{
string typeName = typeof(T).Name;
// Only add if not already present (idempotent operation)
if (!BillingService.Billing.ContainsKey(code))
{
BillingService.Billing.Add(code, getter);
}
else if (!BillingService.GlobalBillingMap.ContainsKey(typeName) ||
BillingService.GlobalBillingMap[typeName] != code)
{
throw new InvalidOperationException($"Billing setup: code '{code}' already registered");
}
if (!BillingService.GlobalBillingMap.ContainsKey(typeName))
{
BillingService.GlobalBillingMap.Add(typeName, code);
}
else if (BillingService.GlobalBillingMap[typeName] != code)
if (BillingService.GlobalBillingMap.ContainsKey(typeName))
{
throw new InvalidOperationException($"Billing setup: type '{typeName}' already registered with different code");
}
if (BillingService.Billing.ContainsKey(code))
{
throw new InvalidOperationException($"Billing setup: code '{code}' already registered with different type");
}
BillingService.Billing.Add(code, getter);
}
}

View file

@ -348,7 +348,6 @@ namespace Yavsc.Models
public DbSet<PersistedGrant> PersistedGrants { get; set; }
public DbSet<DeviceFlowCodes> DeviceFlowCodes { get; set; }
public DbSet<YavscApiScope> YavscApiScopes { get; set; }
public string NOW_SQL { get; private set; }
}
}