feat: implement module purchase dialog with subscription type selection, auto-renew, and dependency checks, replacing the dedicated purchase page.

This commit is contained in:
2025-12-03 01:31:25 +01:00
parent a4e0c276c6
commit 6e427e0199
7 changed files with 361 additions and 17 deletions

View File

@@ -244,7 +244,7 @@ public class ModulesController : ControllerBase
Dependencies = module.GetDependencies().ToList(),
RoutePath = module.RoutePath,
IsAvailable = module.IsAvailable,
IsEnabled = module.IsCore || (module.Subscription?.IsValid() ?? false),
IsEnabled = module.IsCore || ((module.Subscription?.IsEnabled ?? false) && (module.Subscription?.IsValid() ?? false)),
Subscription = module.Subscription != null ? MapSubscriptionToDto(module.Subscription) : null
};
}

View File

@@ -87,7 +87,7 @@ public class ModuleService
if (module.IsCore)
return true;
return module.Subscription?.IsValid() ?? false;
return (module.Subscription?.IsEnabled ?? false) && (module.Subscription?.IsValid() ?? false);
}
/// <summary>
@@ -200,7 +200,7 @@ public class ModuleService
// Verifica se altri moduli dipendono da questo
var dependentModules = await GetDependentModulesAsync(code);
var activeDependents = dependentModules.Where(m => m.Subscription?.IsValid() ?? false).ToList();
var activeDependents = dependentModules.Where(m => (m.Subscription?.IsEnabled ?? false) && (m.Subscription?.IsValid() ?? false)).ToList();
if (activeDependents.Any())
throw new InvalidOperationException(
$"I seguenti moduli attivi dipendono da questo modulo: {string.Join(", ", activeDependents.Select(m => m.Name))}");

View File

@@ -72,9 +72,6 @@ public class ModuleSubscription : BaseEntity
/// </summary>
public bool IsValid()
{
if (!IsEnabled)
return false;
// Se non c'è data di scadenza, è valido (licenza perpetua o core module)
if (!EndDate.HasValue)
return true;