better
This commit is contained in:
parent
65db349c0a
commit
5620213cf5
5 changed files with 33 additions and 47 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue