feat/Update_Controllers_to_Allow_for_Premium_Membership

This commit is contained in:
cesnimda
2026-08-03 09:17:28 +02:00
parent de937d25dc
commit c3f4a57195
187 changed files with 26062 additions and 991 deletions
+8 -5
View File
@@ -1,17 +1,20 @@
namespace JobTrackerApi.Models;
public sealed record AccountEntitlements(bool AdvancedAi, bool PremiumThemes, bool Automation, bool Analytics, long StorageBytes, int MonthlyAiCalls, long MonthlyAiTokens);
public sealed record AccountEntitlements(bool Ai, bool ProThemes, long StorageBytes, int MonthlyAiCalls, long MonthlyAiTokens);
public static class AccountPlans
{
public static bool IsPremiumSubscriptionStatus(string? status) =>
status is "active" or "trialing";
public static AccountEntitlements ForRoles(IList<string> roles)
public static AccountEntitlements ForRoles(IList<string>? roles)
{
var premium = roles.Contains("Premium", StringComparer.OrdinalIgnoreCase) || roles.Contains("Admin", StringComparer.OrdinalIgnoreCase);
var premium = roles?.Contains("Premium", StringComparer.OrdinalIgnoreCase) == true
|| roles?.Contains("Admin", StringComparer.OrdinalIgnoreCase) == true;
return premium
? new AccountEntitlements(true, true, true, true, 5_000_000_000, 250, 1_000_000)
: new AccountEntitlements(false, false, false, false, 250_000_000, 25, 100_000);
? new AccountEntitlements(true, true, 5_000_000_000, 250, 1_000_000)
: new AccountEntitlements(false, false, 250_000_000, 0, 0);
}
public static string Name(AccountEntitlements entitlements) => entitlements.Ai ? "pro" : "free";
}